Example #1
0
 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()
Example #2
0
 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()
Example #3
0
 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()
Example #4
0
 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()