-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Refactor config #340
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
Refactor config #340
Conversation
…ill be useful for testing
…g dict at construction, and not when the Camera class is defined as it was previously done
… only differ in whitespace. Moreover, by the time that this PR is merged, the test_logging file will have been deleted by #335
I think @Aathish04 is better to take a look at that, as he wrote these tests. But personally, this seems very fine to me. (Nevertheless, #335 does not aim to change logging tests, not atm) |
huguesdevimeux
left a comment
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.
Your test fix is I think not good.
I think it's because the log_width parameters in the config is not right, as it should be set to 512.
One way to fix it would be to create a custom .cfg with log_width = 512 and to use it in the CLI in the logging test. That's what I did in #335
cc @Aathish04 (author of this test)
|
Ok, fixed the tests thanks to @Aathish04. Now we need one more approval. |
This is one of a series of PRs aimed at fixing #337. This PR does a few things:
Introduces the
tempconfigcontext manager. This works as follows:So it temporarily changes the config so that all classes that use it for default values will use the new (temporary) config. After
the
withstatement ends, the config is restored. This accounts for the diff inconfig.py,__init__, andtest_config.py. I remember @PgBiel in the past requested the feature of changing the globalconfig. Now we can do it!The problem with the code above is that
Camerainstances used the value offrame_widththat was available at the time when theCameraclass was being defined, not the value of theconfigat the time that the instance was being constructed. So I had to remove a few keys fromCamera.CONFIGand set them inCamera.__init__instead. I did it in a way that it will later be easy to change toattrscc @PgBiel. This accounts for the diff incamera.pyandtest_camera.pyFor some reason my changes made a difference in
test_logging.py. I made it so that this test doesn't care about whitespace in the logs and now it works. I believe this is a fair change for now since apparently Refactored tests and added new tests tools for videos-tests. #335 is going to deprecate how tests currently work. cc @huguesdevimeuxHope this makes sense! This is just the first in a few PRs concerning the config system.