##// END OF EJS Templates
Refactor test to get rid of deprecation....
Matthias Bussonnier -
Show More
@@ -6,7 +6,9 b''
6
6
7
7
8 from collections import Counter, defaultdict, deque, OrderedDict
8 from collections import Counter, defaultdict, deque, OrderedDict
9 import types, string
9 import types
10 import string
11 import unittest
10
12
11 import nose.tools as nt
13 import nose.tools as nt
12
14
@@ -181,44 +183,46 b' class SA(object):'
181 class SB(SA):
183 class SB(SA):
182 pass
184 pass
183
185
184 def test_super_repr():
186 class TestsPretty(unittest.TestCase):
185 # "<super: module_name.SA, None>"
187
186 output = pretty.pretty(super(SA))
188 def test_super_repr(self):
187 nt.assert_regexp_matches(output, r"<super: \S+.SA, None>")
189 # "<super: module_name.SA, None>"
188
190 output = pretty.pretty(super(SA))
189 # "<super: module_name.SA, <module_name.SB at 0x...>>"
191 self.assertRegex(output, r"<super: \S+.SA, None>")
190 sb = SB()
192
191 output = pretty.pretty(super(SA, sb))
193 # "<super: module_name.SA, <module_name.SB at 0x...>>"
192 nt.assert_regexp_matches(output, r"<super: \S+.SA,\s+<\S+.SB at 0x\S+>>")
194 sb = SB()
193
195 output = pretty.pretty(super(SA, sb))
194
196 self.assertRegex(output, r"<super: \S+.SA,\s+<\S+.SB at 0x\S+>>")
195 def test_long_list():
197
196 lis = list(range(10000))
198
197 p = pretty.pretty(lis)
199 def test_long_list(self):
198 last2 = p.rsplit('\n', 2)[-2:]
200 lis = list(range(10000))
199 nt.assert_equal(last2, [' 999,', ' ...]'])
201 p = pretty.pretty(lis)
200
202 last2 = p.rsplit('\n', 2)[-2:]
201 def test_long_set():
203 self.assertEqual(last2, [' 999,', ' ...]'])
202 s = set(range(10000))
204
203 p = pretty.pretty(s)
205 def test_long_set(self):
204 last2 = p.rsplit('\n', 2)[-2:]
206 s = set(range(10000))
205 nt.assert_equal(last2, [' 999,', ' ...}'])
207 p = pretty.pretty(s)
206
208 last2 = p.rsplit('\n', 2)[-2:]
207 def test_long_tuple():
209 self.assertEqual(last2, [' 999,', ' ...}'])
208 tup = tuple(range(10000))
210
209 p = pretty.pretty(tup)
211 def test_long_tuple(self):
210 last2 = p.rsplit('\n', 2)[-2:]
212 tup = tuple(range(10000))
211 nt.assert_equal(last2, [' 999,', ' ...)'])
213 p = pretty.pretty(tup)
212
214 last2 = p.rsplit('\n', 2)[-2:]
213 def test_long_dict():
215 self.assertEqual(last2, [' 999,', ' ...)'])
214 d = { n:n for n in range(10000) }
216
215 p = pretty.pretty(d)
217 def test_long_dict(self):
216 last2 = p.rsplit('\n', 2)[-2:]
218 d = { n:n for n in range(10000) }
217 nt.assert_equal(last2, [' 999: 999,', ' ...}'])
219 p = pretty.pretty(d)
218
220 last2 = p.rsplit('\n', 2)[-2:]
219 def test_unbound_method():
221 self.assertEqual(last2, [' 999: 999,', ' ...}'])
220 output = pretty.pretty(MyObj.somemethod)
222
221 nt.assert_in('MyObj.somemethod', output)
223 def test_unbound_method(self):
224 output = pretty.pretty(MyObj.somemethod)
225 self.assertIn('MyObj.somemethod', output)
222
226
223
227
224 class MetaClass(type):
228 class MetaClass(type):
@@ -8,6 +8,7 b' import os'
8 import shutil
8 import shutil
9 import sys
9 import sys
10 import tempfile
10 import tempfile
11 import unittest
11 from contextlib import contextmanager
12 from contextlib import contextmanager
12 from unittest.mock import patch
13 from unittest.mock import patch
13 from os.path import join, abspath
14 from os.path import join, abspath
@@ -317,7 +318,7 b' def test_unicode_in_filename():'
317 str(ex)
318 str(ex)
318
319
319
320
320 class TestShellGlob(object):
321 class TestShellGlob(unittest.TestCase):
321
322
322 @classmethod
323 @classmethod
323 def setUpClass(cls):
324 def setUpClass(cls):
General Comments 0
You need to be logged in to leave comments. Login now