コード例 #1
0
ファイル: test_path.py プロジェクト: jaraco/path.py
 def test_context_manager_exception(self):
     """
     The context manager will not clean up if an exception occurs.
     """
     d = TempDir()
     d.__enter__()
     (d / 'somefile.txt').touch()
     assert not isinstance(d / 'somefile.txt', TempDir)
     d.__exit__(TypeError, TypeError('foo'), None)
     assert d.exists()
コード例 #2
0
ファイル: test_path.py プロジェクト: louis-ng/path
 def test_context_manager_exception(self):
     """
     The context manager will not clean up if an exception occurs.
     """
     d = TempDir()
     d.__enter__()
     (d / 'somefile.txt').touch()
     assert not isinstance(d / 'somefile.txt', TempDir)
     d.__exit__(TypeError, TypeError('foo'), None)
     assert d.exists()
コード例 #3
0
ファイル: test_path.py プロジェクト: jaraco/path.py
 def test_context_manager(self):
     """
     One should be able to use a TempDir object as a context, which will
     clean up the contents after.
     """
     d = TempDir()
     res = d.__enter__()
     assert res == path.Path(d)
     (d / 'somefile.txt').touch()
     assert not isinstance(d / 'somefile.txt', TempDir)
     d.__exit__(None, None, None)
     assert not d.exists()
コード例 #4
0
ファイル: test_path.py プロジェクト: louis-ng/path
 def test_context_manager(self):
     """
     One should be able to use a TempDir object as a context, which will
     clean up the contents after.
     """
     d = TempDir()
     res = d.__enter__()
     assert res == path.Path(d)
     (d / 'somefile.txt').touch()
     assert not isinstance(d / 'somefile.txt', TempDir)
     d.__exit__(None, None, None)
     assert not d.exists()