Introduce @env_spec for declarative test environments#250
Introduce @env_spec for declarative test environments#250LukeMathWalker wants to merge 1 commit into
Conversation
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #250 +/- ##
==========================================
+ Coverage 32.46% 35.13% +2.67%
==========================================
Files 17 18 +1
Lines 2597 2755 +158
==========================================
+ Hits 843 968 +125
- Misses 1754 1787 +33
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
|
||
| if len(test_args) > 0 and not test.is_method: | ||
| # For bound methods, drop the implicit ``self`` so we can detect a | ||
| # declared ``env`` parameter the same way for functions and methods. |
There was a problem hiding this comment.
I'm not sure I understand the class-method change here.
We now accept tests like
class Test_my_test:
def test_my_test(self, env):
...and pass the env from the spec, if there's one? How do we pass the spec in this case?
| spec = {} | ||
|
|
||
| if module is not None: | ||
| m = getattr(module, 'ENV_SPEC', None) |
There was a problem hiding this comment.
Is this internal? When do we expect to have it?
| if owner_class is not None: | ||
| # ``@env_spec`` decoration on the class itself writes to ``_ATTR``. | ||
| c = getattr(owner_class, _ATTR, None) | ||
| if c is not None: | ||
| declared = True | ||
| spec.update(c) | ||
|
|
||
| if test_func is not None: | ||
| f = getattr(test_func, _ATTR, None) | ||
| if f is not None: | ||
| declared = True | ||
| spec.update(f) |
There was a problem hiding this comment.
Since we only use one of them at a time, with the same logic, and since Python is not type-strict, consider unifying the API for both cases, and make this single param mandatory
A building block which, later on, can be used by the scheduling pipeline to maximise env reuse across tests in the same suite.
You can see it in action in RediSearch/RediSearch#9706