简体   繁体   English

PTVS:单元测试源路径

[英]PTVS: unit test source path

Using Python Tools for Visual Studio, I created a 'project from exisiting source'. 使用适用于Visual Studio的Python工具,我创建了一个“从现有资源中获取项目”。 I can run it's main application file, but every unit test (automatically discovered!) fails to start: 可以运行它的主应用程序文件,但是每个单元测试(自动发现!)都无法启动:

ImportError: No Module named src.xyz.unit.TestThisAndThat

My python sources are in a folder called 'src', which isn't a package. 我的python源位于名为“ src”的文件夹中,该文件夹不是软件包。 In this case, I'm looking for a way to configure the 'source' path. 在这种情况下,我正在寻找一种配置“源”路径的方法。

Summarizing: 总结:

How can I configure the source path to use for running unit tests? 如何配置用于运行单元测试的源路径?

一种选择(尽管不是那么可扩展)是将项目的路径-'... path_to / src'添加到系统变量PYTHONPATH并重新启动ptvs。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM