-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed
Labels
plugin: noserelated to the nose integration builtin pluginrelated to the nose integration builtin plugintype: bugproblem that needs to be addressedproblem that needs to be addressed
Description
The current nose plugin does this:
Lines 21 to 32 in 842814c
if not call_optional(func.obj, "setup"): | |
# Call module level setup if there is no object level one. | |
assert func.parent is not None | |
call_optional(func.parent.obj, "setup") # type: ignore[attr-defined] | |
def teardown_nose() -> None: | |
if not call_optional(func.obj, "teardown"): | |
assert func.parent is not None | |
call_optional(func.parent.obj, "teardown") # type: ignore[attr-defined] | |
# XXX This implies we only call teardown when setup worked. | |
func.addfinalizer(teardown_nose) |
If the module defines setup
, the plugin calls it for every test function (like pytest's setup_function
). But nose calls it once for the module (like pytest's setup_module
).
Furthermore, it seems to assume func.parent
will be a Module
, but when inside a test class it will be an Instance
, i.e. it will call the class's setup
(and won't look at the module).
Finally, the "if there is no object level one" is incorrect -- the module-level setup should be called regardless of whether there is an object-level one.
The func.parent
is causing some problems for a refactor I'm trying to perform, so I'll look into fixing this.
Metadata
Metadata
Assignees
Labels
plugin: noserelated to the nose integration builtin pluginrelated to the nose integration builtin plugintype: bugproblem that needs to be addressedproblem that needs to be addressed