##// 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):
187
188 def test_super_repr(self):
185 # "<super: module_name.SA, None>"
189 # "<super: module_name.SA, None>"
186 output = pretty.pretty(super(SA))
190 output = pretty.pretty(super(SA))
187 nt.assert_regexp_matches(output, r"<super: \S+.SA, None>")
191 self.assertRegex(output, r"<super: \S+.SA, None>")
188
192
189 # "<super: module_name.SA, <module_name.SB at 0x...>>"
193 # "<super: module_name.SA, <module_name.SB at 0x...>>"
190 sb = SB()
194 sb = SB()
191 output = pretty.pretty(super(SA, sb))
195 output = pretty.pretty(super(SA, sb))
192 nt.assert_regexp_matches(output, r"<super: \S+.SA,\s+<\S+.SB at 0x\S+>>")
196 self.assertRegex(output, r"<super: \S+.SA,\s+<\S+.SB at 0x\S+>>")
193
197
194
198
195 def test_long_list():
199 def test_long_list(self):
196 lis = list(range(10000))
200 lis = list(range(10000))
197 p = pretty.pretty(lis)
201 p = pretty.pretty(lis)
198 last2 = p.rsplit('\n', 2)[-2:]
202 last2 = p.rsplit('\n', 2)[-2:]
199 nt.assert_equal(last2, [' 999,', ' ...]'])
203 self.assertEqual(last2, [' 999,', ' ...]'])
200
204
201 def test_long_set():
205 def test_long_set(self):
202 s = set(range(10000))
206 s = set(range(10000))
203 p = pretty.pretty(s)
207 p = pretty.pretty(s)
204 last2 = p.rsplit('\n', 2)[-2:]
208 last2 = p.rsplit('\n', 2)[-2:]
205 nt.assert_equal(last2, [' 999,', ' ...}'])
209 self.assertEqual(last2, [' 999,', ' ...}'])
206
210
207 def test_long_tuple():
211 def test_long_tuple(self):
208 tup = tuple(range(10000))
212 tup = tuple(range(10000))
209 p = pretty.pretty(tup)
213 p = pretty.pretty(tup)
210 last2 = p.rsplit('\n', 2)[-2:]
214 last2 = p.rsplit('\n', 2)[-2:]
211 nt.assert_equal(last2, [' 999,', ' ...)'])
215 self.assertEqual(last2, [' 999,', ' ...)'])
212
216
213 def test_long_dict():
217 def test_long_dict(self):
214 d = { n:n for n in range(10000) }
218 d = { n:n for n in range(10000) }
215 p = pretty.pretty(d)
219 p = pretty.pretty(d)
216 last2 = p.rsplit('\n', 2)[-2:]
220 last2 = p.rsplit('\n', 2)[-2:]
217 nt.assert_equal(last2, [' 999: 999,', ' ...}'])
221 self.assertEqual(last2, [' 999: 999,', ' ...}'])
218
222
219 def test_unbound_method():
223 def test_unbound_method(self):
220 output = pretty.pretty(MyObj.somemethod)
224 output = pretty.pretty(MyObj.somemethod)
221 nt.assert_in('MyObj.somemethod', output)
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