##// END OF EJS Templates
Use proper xunit format for some test....
Matthias Bussonnier -
Show More
@@ -66,21 +66,24 b' def test_io_init():'
66 # just test for string equality.
66 # just test for string equality.
67 assert 'IPython.utils.io.IOStream' in classname, classname
67 assert 'IPython.utils.io.IOStream' in classname, classname
68
68
69 def test_IOStream_init():
69 class TestIOStream(unittest.TestCase):
70
71 def test_IOStream_init(self):
70 """IOStream initializes from a file-like object missing attributes. """
72 """IOStream initializes from a file-like object missing attributes. """
71 # Cause a failure from getattr and dir(). (Issue #6386)
73 # Cause a failure from getattr and dir(). (Issue #6386)
72 class BadStringIO(StringIO):
74 class BadStringIO(StringIO):
73 def __dir__(self):
75 def __dir__(self):
74 attrs = super(StringIO, self).__dir__()
76 attrs = super().__dir__()
75 attrs.append('name')
77 attrs.append('name')
76 return attrs
78 return attrs
77
79 with self.assertWarns(DeprecationWarning):
78 iostream = IOStream(BadStringIO())
80 iostream = IOStream(BadStringIO())
79 iostream.write('hi, bad iostream\n')
81 iostream.write('hi, bad iostream\n')
82
80 assert not hasattr(iostream, 'name')
83 assert not hasattr(iostream, 'name')
81 iostream.close()
84 iostream.close()
82
85
83 def test_capture_output():
86 def test_capture_output(self):
84 """capture_output() context works"""
87 """capture_output() context works"""
85
88
86 with capture_output() as io:
89 with capture_output() as io:
@@ -89,5 +92,3 b' def test_capture_output():'
89
92
90 nt.assert_equal(io.stdout, 'hi, stdout\n')
93 nt.assert_equal(io.stdout, 'hi, stdout\n')
91 nt.assert_equal(io.stderr, 'hi, stderr\n')
94 nt.assert_equal(io.stderr, 'hi, stderr\n')
92
93
@@ -263,9 +263,12 b' def test_get_long_path_name():'
263 p = path.get_long_path_name('/usr/local')
263 p = path.get_long_path_name('/usr/local')
264 nt.assert_equal(p,'/usr/local')
264 nt.assert_equal(p,'/usr/local')
265
265
266
267 class TestRaiseDeprecation(unittest.TestCase):
268
266 @dec.skip_win32 # can't create not-user-writable dir on win
269 @dec.skip_win32 # can't create not-user-writable dir on win
267 @with_environment
270 @with_environment
268 def test_not_writable_ipdir():
271 def test_not_writable_ipdir(self):
269 tmpdir = tempfile.mkdtemp()
272 tmpdir = tempfile.mkdtemp()
270 os.name = "posix"
273 os.name = "posix"
271 env.pop('IPYTHON_DIR', None)
274 env.pop('IPYTHON_DIR', None)
@@ -282,7 +285,7 b' def test_not_writable_ipdir():'
282 # I can still write to an unwritable dir,
285 # I can still write to an unwritable dir,
283 # assume I'm root and skip the test
286 # assume I'm root and skip the test
284 raise SkipTest("I can't create directories that I can't write to")
287 raise SkipTest("I can't create directories that I can't write to")
285 with AssertPrints('is not a writable location', channel='stderr'):
288 with self.assertWarnsRegex(UserWarning, 'is not a writable location'):
286 ipdir = paths.get_ipython_dir()
289 ipdir = paths.get_ipython_dir()
287 env.pop('IPYTHON_DIR', None)
290 env.pop('IPYTHON_DIR', None)
288
291
@@ -313,7 +316,7 b' def test_unicode_in_filename():'
313 """
316 """
314 try:
317 try:
315 # these calls should not throw unicode encode exceptions
318 # these calls should not throw unicode encode exceptions
316 path.get_py_filename('fooéè.py', force_win32=False)
319 path.get_py_filename('fooéè.py')
317 except IOError as ex:
320 except IOError as ex:
318 str(ex)
321 str(ex)
319
322
@@ -406,7 +409,7 b' def test_ensure_dir_exists():'
406 with nt.assert_raises(IOError):
409 with nt.assert_raises(IOError):
407 path.ensure_dir_exists(f)
410 path.ensure_dir_exists(f)
408
411
409 class TestLinkOrCopy(object):
412 class TestLinkOrCopy(unittest.TestCase):
410 def setUp(self):
413 def setUp(self):
411 self.tempdir = TemporaryDirectory()
414 self.tempdir = TemporaryDirectory()
412 self.src = self.dst("src")
415 self.src = self.dst("src")
General Comments 0
You need to be logged in to leave comments. Login now