You can rename your test_runner.py
to runner.py
, this way nose does not treat your test runner as a test itself.
Question
I am trying to run test with nose and here is project structure:
ForTest
├── test_module
│ └── test_suite.py
└── test_runner.py
test_suite.py contains:
def test_1():
pass
def test_2():
pass
and test_runner.py contains next:
import nose
nose.main(argv=['','-v']).run_and_exit()
when I run test_runner.py I have next content in output:
test_suite.test_1 ... ok
test_suite.test_2 ... ok
test_suite.test_1 ... ok
test_suite.test_2 ... ok
----------------------------------------------------------------------
Ran 2 tests in 0.002s
OK
Nose runs tests twice. If I connect myself plugin, I can see, for example, that mehtod addSuccess() calls 4 times. Could you explain me, why do I get this behaviour and how can I prevent it?
La solution
Autres conseils
If you are using setup_module() and teardown_module() in your test file and define: @with(setup_module,teardown_module)
def test_1():
pass
then you need to remove @with(setup_module,teardown_module) from your file, this is making your tests run twice.
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow