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