Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nose runs tests twice

Tags:

python

nose

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?

like image 298
Alexey Avatar asked Oct 03 '22 01:10

Alexey


1 Answers

You can rename your test_runner.py to runner.py, this way nose does not treat your test runner as a test itself.

like image 71
Oleksiy Avatar answered Oct 13 '22 11:10

Oleksiy