擅长:python、mysql、java
<h2>以<code>test_</code>或<code>_test.py</code>结尾开始文件名和测试。类应该以<code>Test</code>开头</h2>
<p>目录示例:<br/>
|--文件<br/>
|--|--材料中的材料<br/>
|--|--|--单调乏味<br/>
|--|--示例.py<br/>
|<br/>
|--测试<br/>
|--|--材料中的材料<br/>
|--|--|--测试时间<br/>
|--|--测试示例.py</p>
<p>在终端:<code>$ py.test --cov=files/ tests/</code>或者只要<code>$ py.test tests/</code>如果你不需要代码覆盖。测试目录文件路径必须在当前目录路径中。或者一个确切的文件路径</p>
<p>使用上面的终端命令(<code>$ py.test tests/</code>),pytest将在<strong>tests/</strong>目录中搜索以<code>test_</code>开头的所有文件。文件也是如此。</p>
<p>测试示例.py</p>
<pre><code># imports here
def test_try_this():
assert 1 == 1
# or
class TestThis:
assert 1 == 0
# or even:
def what_test():
assert True
</code></pre>