0
沒有找到測試我有以下結構,我的包nosetests在子目錄
Project
- __init__.py
- my_mod
-- test
-- __init__.py
-- test_my_mod.py
如果我跑在項目文件夾中的nosetests沒有找到我的測試,但如果我在測試文件夾中運行,然後它拿起它。
任何想法可能是什麼問題
沒有找到測試我有以下結構,我的包nosetests在子目錄
Project
- __init__.py
- my_mod
-- test
-- __init__.py
-- test_my_mod.py
如果我跑在項目文件夾中的nosetests沒有找到我的測試,但如果我在測試文件夾中運行,然後它拿起它。
任何想法可能是什麼問題
刪除__init__.py
文件在您的項目目錄。它看起來不像你打算將Project作爲一個Python包,所以你不需要它。然後,將具有這樣的目錄結構:
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
運行nosetests
內項目現在運行測試,無論是my_mod /目錄內和測試/目錄裏面。
當然,測試文件的內容應包含的東西,nosetests
可以識別作爲測試,如:
import unittest
from my_mod import some_module
class MyTestCase(unittest.TestCase):
def test_the_number(self):
assert some_module.double(10) == 20