我在pycharm中调试单元测试时遇到了问题。我可以使用我的配置正常运行它们,但是当我运行调试器时,我会得到以下错误输出:
错误 Traceback (most recent call last): File "/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/unittest/case.py", line 59, in testPartExecutor yield File "/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/unittest/case.py", line 605, in run testMethod() File "/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/unittest/loader.py", line 34, in testFailure raise self._exception ImportError: 导入测试模块失败:tests Traceback (most recent call last): File "/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/unittest/loader.py", line 462, in _find_test_path package = self._get_module_from_name(name) File "/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/unittest/loader.py", line 369, in _get_module_from_name __import__(name) File "/Users/paymahn/solvvy/scheduler/tests/__init__.py", line 2, in import tests.test_setup_script File "/Users/paymahn/solvvy/scheduler/tests/test_setup_script.py", line 3, in import setup File "/Applications/PyCharm.app/Contents/helpers/pydev/setup.py", line 87, in data_files.append(('pydevd_attach_to_process', [os.path.join('pydevd_attach_to_process', f) for f in os.listdir('pydevd_attach_to_process') if accept_file(f)])) FileNotFoundError: [Errno 2] 没有这样的文件或目录:'pydevd_attach_to_process'
我的目录结构如下:
我的unittest配置如下:
tests/test_setup_script.py
的代码如下:
导入unittest和os模块,以及setup.py文件的路径。在运行测试用例时,调用load_yaml_configuration函数并传递valid-yaml.yml文件名作为参数。该函数将读取文件并返回YAML格式的配置数据。没有断言,因为想要调试上面的代码。
pydevd_attach_to_process
是什么?如何确保在调试过程中找到它?问题实际上与文件/目录是否被找到无关吗?
文件->设置->项目:....->项目解释器->'+'->pydevd->安装包
- nanotek