-
Notifications
You must be signed in to change notification settings - Fork 272
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
Close Temporary file handles in tests #1363
Close Temporary file handles in tests #1363
Conversation
Signed-off-by: Mark Reid <mindmark@gmail.com>
Codecov Report
@@ Coverage Diff @@
## main #1363 +/- ##
=======================================
Coverage 86.27% 86.27%
=======================================
Files 196 196
Lines 19865 19871 +6
Branches 2309 2309
=======================================
+ Hits 17138 17144 +6
Misses 2161 2161
Partials 566 566
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
This looks like a good step forward to me. I always find Python's scoping rules for file handles confusing, and in this case the code really just wants a unique filename, not an actual file handle. Is there a standard pattern for cleaning up temp files in unit tests that we should be using here? |
Currently some tests use def setUp(self):
self.tmpDir = tempfile.mkdtemp()
def tearDown(self):
shutil.rmtree(self.tmpDir) Some tests are using with tempfile.TemporaryDirectory() as temp_dir:
temp_file = os.path.join(temp_dir, "test_basic.otio") Some tests are not cleaning up at all. In |
If we were using Pytest (and here not just as a runner), we would get all these features. But that's for another day. |
There is some other discussion about using pytest here: #1364 I'm fine accepting this PR as-is, and then we can look into the improvements that pytest could give us as a separate change. |
Signed-off-by: Mark Reid <mindmark@gmail.com> Signed-off-by: Michele Spina <michelespina96@gmail.com>
I noticed these file handles were leaking when running tests on mingw64.
I matched the style that's in the files, but I think it would be better to use a
TemporaryDirectory
and cleanup when the test is done. Some tests are doing that, but it is a bit mixed.