Show More
@@ -1,28 +1,28 b'' | |||||
1 | #----------------------------------------------------------------------------- |
|
1 | #----------------------------------------------------------------------------- | |
2 | # Copyright (C) 2012- The IPython Development Team |
|
2 | # Copyright (C) 2012- The IPython Development Team | |
3 | # |
|
3 | # | |
4 | # Distributed under the terms of the BSD License. The full license is in |
|
4 | # Distributed under the terms of the BSD License. The full license is in | |
5 | # the file COPYING, distributed as part of this software. |
|
5 | # the file COPYING, distributed as part of this software. | |
6 | #----------------------------------------------------------------------------- |
|
6 | #----------------------------------------------------------------------------- | |
7 |
|
7 | |||
8 | import os |
|
8 | import os | |
9 |
|
9 | |||
10 | from IPython.utils.tempdir import NamedFileInTemporaryDirectory |
|
10 | from IPython.utils.tempdir import NamedFileInTemporaryDirectory | |
11 | from IPython.utils.tempdir import TemporaryWorkingDirectory |
|
11 | from IPython.utils.tempdir import TemporaryWorkingDirectory | |
12 |
|
12 | |||
13 |
|
13 | |||
14 | def test_named_file_in_temporary_directory(): |
|
14 | def test_named_file_in_temporary_directory(): | |
15 | with NamedFileInTemporaryDirectory('filename') as file: |
|
15 | with NamedFileInTemporaryDirectory('filename') as file: | |
16 | name = file.name |
|
16 | name = file.name | |
17 | assert not file.closed |
|
17 | assert not file.closed | |
18 | assert os.path.exists(name) |
|
18 | assert os.path.exists(name) | |
19 | file.write(b'test') |
|
19 | file.write(b'test') | |
20 | assert file.closed |
|
20 | assert file.closed | |
21 | assert not os.path.exists(name) |
|
21 | assert not os.path.exists(name) | |
22 |
|
22 | |||
23 | def test_temporary_working_directory(): |
|
23 | def test_temporary_working_directory(): | |
24 | with TemporaryWorkingDirectory() as dir: |
|
24 | with TemporaryWorkingDirectory() as dir: | |
25 | assert os.path.exists(dir) |
|
25 | assert os.path.exists(dir) | |
26 |
assert os.path. |
|
26 | assert os.path.realpath(os.curdir) == os.path.realpath(dir) | |
27 | assert not os.path.exists(dir) |
|
27 | assert not os.path.exists(dir) | |
28 | assert os.path.abspath(os.curdir) != dir |
|
28 | assert os.path.abspath(os.curdir) != dir |
General Comments 0
You need to be logged in to leave comments.
Login now