I have the following structure for my package
Project
- __init__.py
- my_mod
-- test
-- __init__.py
-- test_my_mod.py
If I run the nosetests in the project folder it doesn't find my tests, but if I run in the test folder then it picks it up.
Any ideas what could be the problem
Delete the __init__.py
file in your Project directory. It doesn't look like you intend for Project to be a Python package, so you don't need it. Then, having this directory structure:
Project
└── my_mod
├── __init__.py
├── some_module.py
├── test
│ ├── __init__.py
│ ├── test_my_mod_again.py
│ └── test_my_mod_yet_again.py
└── test_my_mod.py
Running nosetests
inside Project will now run your tests, both inside the my_mod/ directory and inside the test/ directory.
Of course, the contents of the test files should contain something that nosetests
can recognize as a test, such as:
import unittest
from my_mod import some_module
class MyTestCase(unittest.TestCase):
def test_the_number(self):
assert some_module.double(10) == 20
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.