擅长:python、mysql、java
<p>在<code>testenv</code>部分中,必须设置</p>
<pre><code>setenv = PY_IGNORE_IMPORTMISMATCH=1
</code></pre>
<p>或</p>
<pre><code>usedevelop = true
</code></pre>
<p>您可以在pytest bugtracker上阅读有关该问题的更多信息,请参见此处<a href="https://github.com/pytest-dev/pytest/issues/2042" rel="nofollow noreferrer">https://github.com/pytest-dev/pytest/issues/2042</a></p>
<p>虽然我没有在这方面花费太多时间,但我很确定这与您的包的命名有关</p>
<p>主源文件夹名为<code>tfields</code>,您的包名为<code>tfields</code>。问题是,现在安装的包和文件夹都可以在同一名称空间下用于Python</p>
<p>如果我没记错的话,我的<a href="https://github.com/jugmac00/hibpcli" rel="nofollow noreferrer">https://github.com/jugmac00/hibpcli</a>项目也遇到了同样的问题——一旦我将源代码放在<code>src</code>目录中,并且不再调用与包名相同的顶级文件夹,问题就消失了</p>
<p>如果您想深入挖掘,我强烈推荐Hynek Schlawack撰写的关于为什么使用<code>src</code>布局的文章:</p>
<p><a href="https://hynek.me/articles/testing-packaging/" rel="nofollow noreferrer">https://hynek.me/articles/testing-packaging/</a></p>