-
Notifications
You must be signed in to change notification settings - Fork 35
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
Add a scope to dependencies #35
Conversation
By using different scope="" arguments in the dependency mark the user can depend on tests in a different module. Or by using scope="session, depends="all" a test can be skipped if ANY previous test has failed. When depending on a test outside the module its full name must be used i.e. tests/test_a.py::test_a
Still to do:
|
There is an issue with using the pytest nodeid as the default name of tests in session scope: it depends on the invocation of pytest. In the simplest case, the nodeid consists of two parts, separated by As an example, consider a subdirectory I shortly considered to replace the module path in the nodeid with the module name, e.g. stripping the directories. But this would create another problem that the module name may not be unique if there are two different modules with the same name in different subdirectories. The pros and cons of both alternatives:
In the end, I opted for simplicity and keep the nodeids unchanged. But the issue with the dependency from the invocation will require appropriate documentation. |
The hierarchy of nodes in pytest is I guess The
For the moment, I'm inclined to go for option 1 and wait and see if any problems arise in practice. That would also be in line with pytest core (possible values for the |
how dependencies must be referenced depending on the scope.
maxsplit is not a keyword argument for str.split() in Python 2.
DependencyManager.getManager().
Hooray! |
This adds a
scope
argument to thepytest.mark.dependency
marker. The values may be either"session"
,"module"
, or"class"
. The references to other tests in thedepends
argument will be taken with respect to the scope indicated in thescope
argument. The scope defaults to"module"
which is the current behavior of pytest-dependency.This implements and closes #3. It supersedes and closes #29.