-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Change from tempconfig to a config fixture in tests #3853
Conversation
926e962
to
57e96f4
Compare
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 is a great change, thanks! I think we can merge this as-is, ignore the comments about the NamedTemporaryFile
s for now; we should probably work on the tests in a more systematic way anyways.
tmp_cfg = tempfile.NamedTemporaryFile("w", dir=tmp_path, delete=False) | ||
tmp_cfg.write( | ||
""" | ||
[CLI] | ||
media_dir = this_is_my_favorite_path | ||
video_dir = {media_dir}/videos | ||
frame_height = 10 | ||
""", | ||
) | ||
tmp_cfg.close() | ||
config.digest_file(tmp_cfg.name) |
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.
It practically doesn't matter because the tests are run in an isolated environment anyways, but what do you think about rewriting this test such that the config file is deleted in the end? The tests could just be moved inside an appropriate context manager. (I can take care of it.)
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.
That's probably a good idea, I'm all for cleaning up after our messes :)
np.testing.assert_allclose(config.frame_height, 10.0) | ||
np.testing.assert_allclose(config.frame_width, 10.0) | ||
def test_frame_size_if_frame_width(config, using_opengl_renderer, tmp_path): | ||
tmp_cfg = tempfile.NamedTemporaryFile("w", dir=tmp_path, delete=False) |
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.
same comment as above for this test
frame_height = 10 | ||
""", | ||
) | ||
tmp_cfg.close() |
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.
same here
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.
actually, is this the same test as before? 🧐
Before we were often doing
Which is just stupid, and it means that if one test forgets to do that, every test that depends on a value changed in that test is now screwed up. This is impossible to debug.
Instead, we can just create a fixture that resets
config
after every test.