File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -522,12 +522,18 @@ def _inject_setup_module_fixture(self) -> None:
522
522
self .obj , ("setUpModule" , "setup_module" )
523
523
)
524
524
if setup_module is None and has_nose :
525
+ # The name "setup" is too common - only treat as fixture if callable.
525
526
setup_module = _get_first_non_fixture_func (self .obj , ("setup" ,))
527
+ if not callable (setup_module ):
528
+ setup_module = None
526
529
teardown_module = _get_first_non_fixture_func (
527
530
self .obj , ("tearDownModule" , "teardown_module" )
528
531
)
529
532
if teardown_module is None and has_nose :
530
533
teardown_module = _get_first_non_fixture_func (self .obj , ("teardown" ,))
534
+ # Same as "setup" above - only treat as fixture if callable.
535
+ if not callable (teardown_module ):
536
+ teardown_module = None
531
537
532
538
if setup_module is None and teardown_module is None :
533
539
return
Original file line number Diff line number Diff line change @@ -477,3 +477,22 @@ def test_raises_baseexception_caught():
477
477
"* 1 failed, 2 passed *" ,
478
478
]
479
479
)
480
+
481
+
482
+ def test_nose_setup_skipped_if_non_callable (pytester : Pytester ) -> None :
483
+ """Regression test for #9391."""
484
+ p = pytester .makepyfile (
485
+ __init__ = "" ,
486
+ setup = """
487
+ """ ,
488
+ teardown = """
489
+ """ ,
490
+ test_it = """
491
+ from . import setup, teardown
492
+
493
+ def test_it():
494
+ pass
495
+ """ ,
496
+ )
497
+ result = pytester .runpytest (p , "-p" , "nose" )
498
+ assert result .ret == 0
You can’t perform that action at this time.
0 commit comments