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