-
Notifications
You must be signed in to change notification settings - Fork 64
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
Shared Contexts can not be extracted into seperate files #128
Comments
With the current implementation using AST transformation this is quite difficult to do in a naive way as far as my understanding goes. The resulting module (including the imports and everything) is not executed until the test is actually run. The Syntax parser actually doesn't know or care what is imported in the test files... In my opinion, you would need a preliminary AST parsing before the actual AST transformation which collects all the shared_contexts which should be shared across files. I see two methods to do that:
# test_one_spec.py
with exported_context('Exported'):
...
with describe(SomeClass):
with included_context('Exported'):
...
# test_two_spec.py
with included_context('Exported'):
...
# exported_shared_context.py
with shared_context('Exported'):
...
# test_two_spec.py
with included_context('Exported'):
... Some problems I see that need to be solved will be:
@nestorsalceda I'm not sure if I'm totally off with something, maybe you see something different, too? |
Thank you for the fast and detailed response. I'd personally prefer your And I have never worked with ast before but that wont keep me from trying. If you have any additional input, let me know. |
As the title suggests I can't find a way to extract my
shared_context
blocks into different files, which makes the feature much less useful.I tried:
included_context
which throws a KeyError as the included_context can'tfind the extracted context.
I'd be very happy to implement this myself. But I could use some pointers on where to start.
The text was updated successfully, but these errors were encountered: