Nose runs test methods when I import the test class

26 views
Skip to first unread message

Thomas Phillips

unread,
Sep 12, 2016, 8:41:19 PM9/12/16
to nose-dev
Hi all

I have a bunch of test scripts with one test class in each, and when I import these classes into another test script (I want to be able to run the test methods when I want as well), the test methods get executed.
How do I stop it doing this?

test_all.py:
from test_class_1 import TestClass1 as Class1

class TestClassAll(object):
   
def test_all(self):
        class1
= Class1()
        class1
.test_method1()

test_class_1.py:
class TestClass1(object):
   
def test_method1(self):
       
assert True


output:
$ nosetests -s test_all.py
..
----------------------------------------------------------------------
Ran 2 tests in 0.005s


OK


How do I get it to only run test_method1 once, when I want to, and not on import?

Thanks
Thomas
Reply all
Reply to author
Forward
0 new messages