##// END OF EJS Templates
Misc modifications for pytest comppatibility...
Matthias Bussonnier -
Show More
@@ -36,7 +36,6 b' from IPython.utils.process import find_cmd'
36 36 # Globals
37 37 #-----------------------------------------------------------------------------
38 38 # This is used by every single test, no point repeating it ad nauseam
39 ip = get_ipython()
40 39
41 40 #-----------------------------------------------------------------------------
42 41 # Tests
@@ -127,8 +126,8 b' class InteractiveShellTestCase(unittest.TestCase):'
127 126 """Pretty-printing lists of objects with non-ascii reprs may cause
128 127 problems."""
129 128 class Spam(object):
130 def __repr__(self):
131 return "\xe9"*50
129 def __repr__(self):
130 return "\xe9"*50
132 131 import IPython.core.formatters
133 132 f = IPython.core.formatters.PlainTextFormatter()
134 133 f([Spam(),Spam()])
@@ -766,7 +765,7 b' class TestAstTransformError(unittest.TestCase):'
766 765 err_transformer = ErrorTransformer()
767 766 ip.ast_transformers.append(err_transformer)
768 767
769 with tt.AssertPrints("unregister", channel='stderr'):
768 with self.assertWarnsRegex(UserWarning, "It will be unregistered"):
770 769 ip.run_cell("1 + 2")
771 770
772 771 # This should have been removed.
@@ -882,9 +881,6 b' def test_user_expression():'
882 881
883 882 # back to text only
884 883 ip.display_formatter.active_types = ['text/plain']
885
886
887
888 884
889 885
890 886 class TestSyntaxErrorTransformer(unittest.TestCase):
@@ -918,25 +914,25 b' class TestSyntaxErrorTransformer(unittest.TestCase):'
918 914 ip.run_cell('3456')
919 915
920 916
921
922 def test_warning_suppression():
923 ip.run_cell("import warnings")
924 try:
925 with tt.AssertPrints("UserWarning: asdf", channel="stderr"):
926 ip.run_cell("warnings.warn('asdf')")
927 # Here's the real test -- if we run that again, we should get the
928 # warning again. Traditionally, each warning was only issued once per
929 # IPython session (approximately), even if the user typed in new and
930 # different code that should have also triggered the warning, leading
931 # to much confusion.
932 with tt.AssertPrints("UserWarning: asdf", channel="stderr"):
933 ip.run_cell("warnings.warn('asdf')")
934 finally:
935 ip.run_cell("del warnings")
917 class TestWarningSupression(unittest.TestCase):
918 def test_warning_suppression(self):
919 ip.run_cell("import warnings")
920 try:
921 with self.assertWarnsRegex(UserWarning, "asdf"):
922 ip.run_cell("warnings.warn('asdf')")
923 # Here's the real test -- if we run that again, we should get the
924 # warning again. Traditionally, each warning was only issued once per
925 # IPython session (approximately), even if the user typed in new and
926 # different code that should have also triggered the warning, leading
927 # to much confusion.
928 with self.assertWarnsRegex(UserWarning, "asdf"):
929 ip.run_cell("warnings.warn('asdf')")
930 finally:
931 ip.run_cell("del warnings")
936 932
937 933
938 def test_deprecation_warning():
939 ip.run_cell("""
934 def test_deprecation_warning(self):
935 ip.run_cell("""
940 936 import warnings
941 937 def wrn():
942 938 warnings.warn(
@@ -944,12 +940,12 b' def wrn():'
944 940 DeprecationWarning
945 941 )
946 942 """)
947 try:
948 with tt.AssertPrints("I AM A WARNING", channel="stderr"):
949 ip.run_cell("wrn()")
950 finally:
951 ip.run_cell("del warnings")
952 ip.run_cell("del wrn")
943 try:
944 with self.assertWarnsRegex(DeprecationWarning, "I AM A WARNING"):
945 ip.run_cell("wrn()")
946 finally:
947 ip.run_cell("del warnings")
948 ip.run_cell("del wrn")
953 949
954 950
955 951 class TestImportNoDeprecate(tt.TempFileMixin):
@@ -18,7 +18,6 b' from IPython.testing import tools as tt'
18 18 #-----------------------------------------------------------------------------
19 19 # Globals
20 20 #-----------------------------------------------------------------------------
21 ip = get_ipython()
22 21
23 22 #-----------------------------------------------------------------------------
24 23 # Test functions begin
@@ -170,7 +169,7 b' class PasteTestCase(TestCase):'
170 169 ip.write = writer
171 170 nt.assert_equal(ip.user_ns['a'], 100)
172 171 nt.assert_equal(ip.user_ns['b'], 200)
173 nt.assert_equal(out, code+"\n## -- End pasted text --\n")
172 assert out == code+"\n## -- End pasted text --\n"
174 173
175 174 def test_paste_leading_commas(self):
176 175 "Test multiline strings with leading commas"
@@ -39,7 +39,7 b' def recursionlimit(frames):'
39 39 def inner(test_function):
40 40 def wrapper(*args, **kwargs):
41 41 _orig_rec_limit = ultratb._FRAME_RECURSION_LIMIT
42 ultratb._FRAME_RECURSION_LIMIT = frames - 50
42 ultratb._FRAME_RECURSION_LIMIT = 50
43 43
44 44 rl = sys.getrecursionlimit()
45 45 sys.setrecursionlimit(frames)
@@ -327,17 +327,17 b' def r3o2():'
327 327 with tt.AssertNotPrints("frames repeated"):
328 328 ip.run_cell("non_recurs()")
329 329
330 @recursionlimit(65)
330 @recursionlimit(150)
331 331 def test_recursion_one_frame(self):
332 332 with tt.AssertPrints("1 frames repeated"):
333 333 ip.run_cell("r1()")
334 334
335 @recursionlimit(65)
335 @recursionlimit(150)
336 336 def test_recursion_three_frames(self):
337 337 with tt.AssertPrints("3 frames repeated"):
338 338 ip.run_cell("r3o2()")
339 339
340 @recursionlimit(65)
340 @recursionlimit(150)
341 341 def test_find_recursion(self):
342 342 captured = []
343 343 def capture_exc(*args, **kwargs):
@@ -128,6 +128,6 b' int()'
128 128 map()
129 129 """
130 130 for c in range(16, 22):
131 yield lambda: expect_token("int", cell, c)
131 yield lambda cell, c: expect_token("int", cell, c), cell, c
132 132 for c in range(22, 28):
133 yield lambda: expect_token("map", cell, c)
133 yield lambda cell, c: expect_token("map", cell, c), cell, c
General Comments 0
You need to be logged in to leave comments. Login now