-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tests for TempfileManager #142
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've one small fixup request.
tests/test_TempfileManager.py
Outdated
class TestTempfileManager(unittest.TestCase): | ||
def test_create_specified(self): | ||
"""Test making a directory in a legal location""" | ||
with TempfileManager('/tmp/test') as ret: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test directory is vulnerable to collisions. I'd recommend using a path inside of a tempdir from tempfile.mkdtemp
tests/test_TempfileManager.py
Outdated
self.assertEqual(ret, '/tmp/test') | ||
# clean up | ||
self.assertTrue(os.path.exists('/tmp/test')) | ||
os.rmdir('/tmp/test') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd recommend shutil.rmtree
here and then you can clean up the full directory tree from mkdtemp in the comment above.
b5763c7
to
50f1e75
Compare
Here's the updated coverage:
|
This is still missing some parts of the file, namely because I'm not sure how to make the
__enter__
pass and the__exit__
fail. @tfoote do you have any ideas for this?