This commit is contained in:
Ronny Pfannschmidt 2015-02-22 12:29:26 +01:00
commit f1c9554f42
3 changed files with 7 additions and 17 deletions

View File

@ -30,15 +30,15 @@ and does not handle Deferreds returned from a test in pytest style.
If you are using trial's unittest.TestCase chances are that you can If you are using trial's unittest.TestCase chances are that you can
just run your tests even if you return Deferreds. In addition, just run your tests even if you return Deferreds. In addition,
there also is a dedicated `pytest-twisted there also is a dedicated `pytest-twisted
<http://pypi.python.org/pypi/pytest-twisted>`_ plugin which allows to <http://pypi.python.org/pypi/pytest-twisted>`_ plugin which allows you to
return deferreds from pytest-style tests, allowing to use return deferreds from pytest-style tests, allowing the use of
:ref:`fixtures` and other features. :ref:`fixtures` and other features.
how does pytest work with Django? how does pytest work with Django?
++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++
In 2012, some work is going into the `pytest-django plugin <http://pypi.python.org/pypi/pytest-django>`_. It substitutes the usage of Django's In 2012, some work is going into the `pytest-django plugin <http://pypi.python.org/pypi/pytest-django>`_. It substitutes the usage of Django's
``manage.py test`` and allows to use all pytest features_ most of which ``manage.py test`` and allows the use of all pytest features_ most of which
are not available from Django directly. are not available from Django directly.
.. _features: features.html .. _features: features.html
@ -49,7 +49,7 @@ What's this "magic" with pytest? (historic notes)
Around 2007 (version ``0.8``) some people thought that ``pytest`` Around 2007 (version ``0.8``) some people thought that ``pytest``
was using too much "magic". It had been part of the `pylib`_ which was using too much "magic". It had been part of the `pylib`_ which
contains a lot of unreleated python library code. Around 2010 there contains a lot of unrelated python library code. Around 2010 there
was a major cleanup refactoring, which removed unused or deprecated code was a major cleanup refactoring, which removed unused or deprecated code
and resulted in the new ``pytest`` PyPI package which strictly contains and resulted in the new ``pytest`` PyPI package which strictly contains
only test-related code. This release also brought a complete pluginification only test-related code. This release also brought a complete pluginification
@ -63,7 +63,7 @@ A second "magic" issue was the assert statement debugging feature.
Nowadays, ``pytest`` explicitely rewrites assert statements in test modules Nowadays, ``pytest`` explicitely rewrites assert statements in test modules
in order to provide more useful :ref:`assert feedback <assertfeedback>`. in order to provide more useful :ref:`assert feedback <assertfeedback>`.
This completely avoids previous issues of confusing assertion-reporting. This completely avoids previous issues of confusing assertion-reporting.
It also means, that you can use Python's ``-O`` optimization without loosing It also means, that you can use Python's ``-O`` optimization without losing
assertions in test modules. assertions in test modules.
``pytest`` contains a second, mostly obsolete, assert debugging technique, ``pytest`` contains a second, mostly obsolete, assert debugging technique,
@ -152,13 +152,13 @@ pytest interaction with other packages
Issues with pytest, multiprocess and setuptools? Issues with pytest, multiprocess and setuptools?
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
On windows the multiprocess package will instantiate sub processes On Windows the multiprocess package will instantiate sub processes
by pickling and thus implicitly re-import a lot of local modules. by pickling and thus implicitly re-import a lot of local modules.
Unfortunately, setuptools-0.6.11 does not ``if __name__=='__main__'`` Unfortunately, setuptools-0.6.11 does not ``if __name__=='__main__'``
protect its generated command line script. This leads to infinite protect its generated command line script. This leads to infinite
recursion when running a test that instantiates Processes. recursion when running a test that instantiates Processes.
As of middle 2013, there shouldn't be a problem anymore when you As of mid-2013, there shouldn't be a problem anymore when you
use the standard setuptools (note that distribute has been merged use the standard setuptools (note that distribute has been merged
back into setuptools which is now shipped directly with virtualenv). back into setuptools which is now shipped directly with virtualenv).

View File

@ -3,8 +3,6 @@ import py, pytest
import pdb import pdb
xfail_if_pdbpp_installed = pytest.mark.xfail(hasattr(pdb, "__author__"),
reason="doctest/pdbpp problem: https://bitbucket.org/antocuni/pdb/issue/24/doctests-fail-when-pdbpp-is-installed", run=False)
class TestDoctests: class TestDoctests:
@ -161,7 +159,6 @@ class TestDoctests:
reprec = testdir.inline_run(p, "--doctest-modules") reprec = testdir.inline_run(p, "--doctest-modules")
reprec.assertoutcome(failed=1) reprec.assertoutcome(failed=1)
@xfail_if_pdbpp_installed
def test_doctestmodule_external_and_issue116(self, testdir): def test_doctestmodule_external_and_issue116(self, testdir):
p = testdir.mkpydir("hello") p = testdir.mkpydir("hello")
p.join("__init__.py").write(py.code.Source(""" p.join("__init__.py").write(py.code.Source("""
@ -201,7 +198,6 @@ class TestDoctests:
"*test_txtfile_failing.txt:2: DocTestFailure" "*test_txtfile_failing.txt:2: DocTestFailure"
]) ])
@xfail_if_pdbpp_installed
def test_txtfile_with_fixtures(self, testdir): def test_txtfile_with_fixtures(self, testdir):
p = testdir.maketxtfile(""" p = testdir.maketxtfile("""
>>> dir = getfixture('tmpdir') >>> dir = getfixture('tmpdir')
@ -211,7 +207,6 @@ class TestDoctests:
reprec = testdir.inline_run(p, ) reprec = testdir.inline_run(p, )
reprec.assertoutcome(passed=1) reprec.assertoutcome(passed=1)
@xfail_if_pdbpp_installed
def test_txtfile_with_usefixtures_in_ini(self, testdir): def test_txtfile_with_usefixtures_in_ini(self, testdir):
testdir.makeini(""" testdir.makeini("""
[pytest] [pytest]
@ -232,7 +227,6 @@ class TestDoctests:
reprec = testdir.inline_run(p, ) reprec = testdir.inline_run(p, )
reprec.assertoutcome(passed=1) reprec.assertoutcome(passed=1)
@xfail_if_pdbpp_installed
def test_doctestmodule_with_fixtures(self, testdir): def test_doctestmodule_with_fixtures(self, testdir):
p = testdir.makepyfile(""" p = testdir.makepyfile("""
''' '''
@ -244,7 +238,6 @@ class TestDoctests:
reprec = testdir.inline_run(p, "--doctest-modules") reprec = testdir.inline_run(p, "--doctest-modules")
reprec.assertoutcome(passed=1) reprec.assertoutcome(passed=1)
@xfail_if_pdbpp_installed
def test_doctestmodule_three_tests(self, testdir): def test_doctestmodule_three_tests(self, testdir):
p = testdir.makepyfile(""" p = testdir.makepyfile("""
''' '''
@ -270,7 +263,6 @@ class TestDoctests:
reprec = testdir.inline_run(p, "--doctest-modules") reprec = testdir.inline_run(p, "--doctest-modules")
reprec.assertoutcome(passed=3) reprec.assertoutcome(passed=3)
@xfail_if_pdbpp_installed
def test_doctestmodule_two_tests_one_fail(self, testdir): def test_doctestmodule_two_tests_one_fail(self, testdir):
p = testdir.makepyfile(""" p = testdir.makepyfile("""
class MyClass: class MyClass:

View File

@ -2,7 +2,6 @@
import py import py
import sys import sys
from test_doctest import xfail_if_pdbpp_installed
class TestPDB: class TestPDB:
def pytest_funcarg__pdblist(self, request): def pytest_funcarg__pdblist(self, request):
@ -187,7 +186,6 @@ class TestPDB:
if child.isalive(): if child.isalive():
child.wait() child.wait()
@xfail_if_pdbpp_installed
def test_pdb_interaction_doctest(self, testdir): def test_pdb_interaction_doctest(self, testdir):
p1 = testdir.makepyfile(""" p1 = testdir.makepyfile("""
import pytest import pytest