<div dir="ltr">We probably want to move to it in ovirt-system-tests as well, to align with both VDSM and Lago itself, no?<div><br><div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername">Nir Soffer</b> <span dir="ltr">&lt;<a href="mailto:nsoffer@redhat.com">nsoffer@redhat.com</a>&gt;</span><br>Date: Thu, Mar 10, 2016 at 3:15 PM<br>Subject: [ovirt-devel] [VDSM] Moving to py.test<br>To: devel &lt;<a href="mailto:devel@ovirt.org">devel@ovirt.org</a>&gt;, Yaniv Bronheim &lt;<a href="mailto:ybronhei@redhat.com">ybronhei@redhat.com</a>&gt;, Dan Kenigsberg &lt;<a href="mailto:danken@redhat.com">danken@redhat.com</a>&gt;, Piotr Kliczewski &lt;<a href="mailto:pkliczew@redhat.com">pkliczew@redhat.com</a>&gt;, Francesco Romani &lt;<a href="mailto:fromani@redhat.com">fromani@redhat.com</a>&gt;, Adam Litke &lt;<a href="mailto:alitke@redhat.com">alitke@redhat.com</a>&gt;<br><br><br>Hi all,<br>
<br>
In the last vdsm call we discussed moving to py.test.<br>
<br>
Here is how to run the current tests with py.test:<br>
<br>
    cd tests<br>
    PYTHONPATH=../lib:../vdsm py.test -v *_test.py *_tests.py *Tests.py network<br>
<br>
Currently we have some failures and errors:<br>
<br>
    8 failed, 1662 passed, 101 skipped, 14 pytest-warnings, 10 error<br>
in 86.05 seconds<br>
<br>
Some py.test nice tricks:<br>
<br>
Finding the 10 slowest tests:<br>
<br>
    PYTHONPATH=../lib:../vdsm py.test -v --durations=10 vmTests.py<br>
*_test.py *_tests.py *Tests.py network<br>
<br>
Checking code coverage:<br>
<br>
    PYTHONPATH=../lib:../vdsm py.test -v --cov=../vdsm --cov=vdsm<br>
*_test.py *_tests.py *Tests.py network<br>
<br>
Once we finish moving vdsm code to lib/vdsm, renaming the tests to<br>
*_test.py, and add<br>
pytest.ini, running the test will be simply:<br>
<br>
    py.test<br>
<br>
Once all the tests pass, we can:<br>
<br>
- Drop all the special asserts (assertXXX), py.test uses plain asserts<br>
  <a href="https://pytest.org/latest/assert.html#asserting-with-the-assert-statement" rel="noreferrer" target="_blank">https://pytest.org/latest/assert.html#asserting-with-the-assert-statement</a><br>
<br>
- Get better error reports<br>
  <a href="https://pytest.org/latest/example/reportingdemo.html" rel="noreferrer" target="_blank">https://pytest.org/latest/example/reportingdemo.html</a><br>
<br>
- Remove unneeded classes, or inherit from any class<br>
  <a href="https://pytest.org/latest/getting-started.html" rel="noreferrer" target="_blank">https://pytest.org/latest/getting-started.html</a><br>
<br>
- Replace @permutations with more powerfull @pytest.mark.parametrize<br>
  <a href="https://pytest.org/latest/parametrize.html#parametrize-basics" rel="noreferrer" target="_blank">https://pytest.org/latest/parametrize.html#parametrize-basics</a><br>
<br>
- Replace slowtest and stresstest with @pytest.mark<br>
  <a href="https://pytest.org/latest/mark.html" rel="noreferrer" target="_blank">https://pytest.org/latest/mark.html</a><br>
<br>
- Replace monkeypatch.py with simpler and more powerfull pytest<br>
monkeypatch funcarg<br>
  <a href="https://pytest.org/latest/monkeypatch.html#monkeypatching-mocking-modules-and-environments" rel="noreferrer" target="_blank">https://pytest.org/latest/monkeypatch.html#monkeypatching-mocking-modules-and-environments</a><br>
<br>
- Replace NamedTemporaryDir with pytest tmpdir funcarg<br>
  <a href="https://pytest.org/latest/getting-started.html#going-functional-requesting-a-unique-temporary-directory" rel="noreferrer" target="_blank">https://pytest.org/latest/getting-started.html#going-functional-requesting-a-unique-temporary-directory</a><br>
<br>
- Simplify complex context managers with pytest fixtures<br>
  <a href="https://pytest.org/latest/example/simple.html" rel="noreferrer" target="_blank">https://pytest.org/latest/example/simple.html</a><br>
<br>
- Drop testrunner.py, most of testlib.py, some of testValidation.py,<br>
run_tests*.sh<br>
<br>
- And more<br>
<br>
Nir<br>
_______________________________________________<br>
Devel mailing list<br>
<a href="mailto:Devel@ovirt.org">Devel@ovirt.org</a><br>
<a href="http://lists.ovirt.org/mailman/listinfo/devel" rel="noreferrer" target="_blank">http://lists.ovirt.org/mailman/listinfo/devel</a><br>
</div><br></div></div>