Possible fix for view_config() referencing old registry #234
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
view_config decorators are called only once for an entire test suite execution.
After tearDown() is called once, further calls to config.scan() fail to update
the registry of the associated renderer of a view, which causes test cases to
fail.
This patch contains a test case to highlight the problem, and a proposed fix.
I have first observed the problem when trying to register some classes during integration testing, and using them for views registered via the view_config() decorator. The first test would pass, and the rest of the tests would fail.
I tracked the problem down to Renderer not picking up my registered renderers after testing.tearDown() is called. Eventually, view_config() turned out to be the cause.
I could have made a more targeted fix that would check config.registry and renderer.registry, and reallocate if they are different, but I chose to re-allocate a renderer every time config.scan() is called.