使用unittest构建Python项目

问题描述

我正在用python练习TDD,目前,我的项目具有以下结构:

App
    A_folder
        init__.py
        core.py
        rand.csv
    B_folder
    test
        __init__.py
        test_A_folder
            __init__.py
            test_some_funtion_in_A_folder.py

在测试类test_some_funtion_in_A_folder.py中,我有一个以Test *开头的类名,我的所有测试均以“ test_”作为前缀。但是我遇到了错误

我通过添加并单击PyCharm中的播放图标来运行测试:

import unittest


class TestSomething(unittest.TestCase):
    def test_something(self):
        self.assertTrue(True)


if __name__ == '__main__':
    unittest.main()

我可以寻求帮助吗?预先感谢。

My error output:
============================= test session starts =============================
platform win32 -- Python 3.7.4,pytest-5.2.1,py-1.8.0,pluggy-0.13.0 -- C:\Users\kroha\Anaconda3\python.exe
cachedir: .pytest_cache
rootdir: {Path}\App
plugins: arraydiff-0.3,doctestplus-0.4.0,openfiles-0.4.0,remotedata-0.3.2
collecting ... ERROR: not found: {Path}\App\test\test_A_folder\test_some_funtion_in_A_folder
(no name '{Path}\App\test\test_A_folder\test_some_funtion_in_A_folder' in any of [])

collected 0 items

============================ no tests ran in 0.01s ============================

Process finished with exit code 4

Empty suite

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)