2017-09-26 26 views
0

没有找到测试我有以下结构,我的包nosetests在子目录

Project 
- __init__.py 
- my_mod 
-- test 
-- __init__.py 
-- test_my_mod.py 

如果我跑在项目文件夹中的nosetests没有找到我的测试,但如果我在测试文件夹中运行,然后它拿起它。

任何想法可能是什么问题

回答

0

删除__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