可以使用无效的模块/软件包python名称pytest文件吗?

时间:2019-11-25 04:07:17

标签: python testing module pytest

我可以在cli中运行python some.code.py

但是我既不能运行pytest some.code.py也不能运行pytest 'some.code.py'

回溯错误为

Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/local/lib/python3.7/site-packages/_pytest/python.py:501: in _importtestmodule
    mod = self.fspath.pyimport(ensuresyspath=importmode)
/usr/local/lib/python3.7/site-packages/py/_path/local.py:701: in pyimport
    __import__(modname)
E   ModuleNotFoundError: No module named 'some'

我了解pytest会将文件作为模块导入,因此它不接受无效的模块名称。但是我正在测试的文件是由另一个应用程序以编程方式生成的。有没有办法在pytest中解决此约束?

0 个答案:

没有答案