commit
						4868d0d97a
					
				| 
						 | 
					@ -0,0 +1,13 @@
 | 
				
			||||||
 | 
					Removed unused support code for `unittest2 <https://pypi.org/project/unittest2/>`__.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					The ``unittest2`` backport module is no longer
 | 
				
			||||||
 | 
					necessary since Python 3.3+, and the small amount of code in pytest to support it also doesn't seem
 | 
				
			||||||
 | 
					to be used: after removed, all tests still pass unchanged.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Although our policy is to introduce a deprecation period before removing any features or support
 | 
				
			||||||
 | 
					for third party libraries, because this code is apparently not used
 | 
				
			||||||
 | 
					at all (even if ``unittest2`` is used by a test suite executed by pytest), it was decided to
 | 
				
			||||||
 | 
					remove it in this release.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					If you experience a regression because of this, please
 | 
				
			||||||
 | 
					`file an issue <https://github.com/pytest-dev/pytest/issues/new>`__.
 | 
				
			||||||
| 
						 | 
					@ -1,31 +1,9 @@
 | 
				
			||||||
""" run test suites written for nose. """
 | 
					""" run test suites written for nose. """
 | 
				
			||||||
import sys
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import pytest
 | 
					 | 
				
			||||||
from _pytest import python
 | 
					from _pytest import python
 | 
				
			||||||
from _pytest import runner
 | 
					 | 
				
			||||||
from _pytest import unittest
 | 
					from _pytest import unittest
 | 
				
			||||||
from _pytest.config import hookimpl
 | 
					from _pytest.config import hookimpl
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def get_skip_exceptions():
 | 
					 | 
				
			||||||
    skip_classes = set()
 | 
					 | 
				
			||||||
    for module_name in ("unittest", "unittest2", "nose"):
 | 
					 | 
				
			||||||
        mod = sys.modules.get(module_name)
 | 
					 | 
				
			||||||
        if hasattr(mod, "SkipTest"):
 | 
					 | 
				
			||||||
            skip_classes.add(mod.SkipTest)
 | 
					 | 
				
			||||||
    return tuple(skip_classes)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
def pytest_runtest_makereport(item, call):
 | 
					 | 
				
			||||||
    if call.excinfo and call.excinfo.errisinstance(get_skip_exceptions()):
 | 
					 | 
				
			||||||
        # let's substitute the excinfo with a pytest.skip one
 | 
					 | 
				
			||||||
        call2 = runner.CallInfo.from_call(
 | 
					 | 
				
			||||||
            lambda: pytest.skip(str(call.excinfo.value)), call.when
 | 
					 | 
				
			||||||
        )
 | 
					 | 
				
			||||||
        call.excinfo = call2.excinfo
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
@hookimpl(trylast=True)
 | 
					@hookimpl(trylast=True)
 | 
				
			||||||
def pytest_runtest_setup(item):
 | 
					def pytest_runtest_setup(item):
 | 
				
			||||||
    if is_potential_nosetest(item):
 | 
					    if is_potential_nosetest(item):
 | 
				
			||||||
| 
						 | 
					@ -40,9 +18,6 @@ def teardown_nose(item):
 | 
				
			||||||
    if is_potential_nosetest(item):
 | 
					    if is_potential_nosetest(item):
 | 
				
			||||||
        if not call_optional(item.obj, "teardown"):
 | 
					        if not call_optional(item.obj, "teardown"):
 | 
				
			||||||
            call_optional(item.parent.obj, "teardown")
 | 
					            call_optional(item.parent.obj, "teardown")
 | 
				
			||||||
        # if hasattr(item.parent, '_nosegensetup'):
 | 
					 | 
				
			||||||
        #    #call_optional(item._nosegensetup, 'teardown')
 | 
					 | 
				
			||||||
        #    del item.parent._nosegensetup
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def is_potential_nosetest(item):
 | 
					def is_potential_nosetest(item):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -249,10 +249,11 @@ def pytest_make_collect_report(collector):
 | 
				
			||||||
    if not call.excinfo:
 | 
					    if not call.excinfo:
 | 
				
			||||||
        outcome = "passed"
 | 
					        outcome = "passed"
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        from _pytest import nose
 | 
					        skip_exceptions = [Skipped]
 | 
				
			||||||
 | 
					        unittest = sys.modules.get("unittest")
 | 
				
			||||||
        skip_exceptions = (Skipped,) + nose.get_skip_exceptions()
 | 
					        if unittest is not None:
 | 
				
			||||||
        if call.excinfo.errisinstance(skip_exceptions):
 | 
					            skip_exceptions.append(unittest.SkipTest)
 | 
				
			||||||
 | 
					        if call.excinfo.errisinstance(tuple(skip_exceptions)):
 | 
				
			||||||
            outcome = "skipped"
 | 
					            outcome = "skipped"
 | 
				
			||||||
            r = collector._repr_failure_py(call.excinfo, "line").reprcrash
 | 
					            r = collector._repr_failure_py(call.excinfo, "line").reprcrash
 | 
				
			||||||
            longrepr = (str(r.path), r.lineno, r.message)
 | 
					            longrepr = (str(r.path), r.lineno, r.message)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -11,6 +11,7 @@ from _pytest.outcomes import skip
 | 
				
			||||||
from _pytest.outcomes import xfail
 | 
					from _pytest.outcomes import xfail
 | 
				
			||||||
from _pytest.python import Class
 | 
					from _pytest.python import Class
 | 
				
			||||||
from _pytest.python import Function
 | 
					from _pytest.python import Function
 | 
				
			||||||
 | 
					from _pytest.runner import CallInfo
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def pytest_pycollect_makeitem(collector, name, obj):
 | 
					def pytest_pycollect_makeitem(collector, name, obj):
 | 
				
			||||||
| 
						 | 
					@ -223,6 +224,14 @@ def pytest_runtest_makereport(item, call):
 | 
				
			||||||
            except AttributeError:
 | 
					            except AttributeError:
 | 
				
			||||||
                pass
 | 
					                pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    unittest = sys.modules.get("unittest")
 | 
				
			||||||
 | 
					    if unittest and call.excinfo and call.excinfo.errisinstance(unittest.SkipTest):
 | 
				
			||||||
 | 
					        # let's substitute the excinfo with a pytest.skip one
 | 
				
			||||||
 | 
					        call2 = CallInfo.from_call(
 | 
				
			||||||
 | 
					            lambda: pytest.skip(str(call.excinfo.value)), call.when
 | 
				
			||||||
 | 
					        )
 | 
				
			||||||
 | 
					        call.excinfo = call2.excinfo
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# twisted trial support
 | 
					# twisted trial support
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -939,9 +939,7 @@ def test_class_method_containing_test_issue1558(testdir):
 | 
				
			||||||
    reprec.assertoutcome(passed=1)
 | 
					    reprec.assertoutcome(passed=1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@pytest.mark.parametrize(
 | 
					@pytest.mark.parametrize("base", ["builtins.object", "unittest.TestCase"])
 | 
				
			||||||
    "base", ["builtins.object", "unittest.TestCase", "unittest2.TestCase"]
 | 
					 | 
				
			||||||
)
 | 
					 | 
				
			||||||
def test_usefixtures_marker_on_unittest(base, testdir):
 | 
					def test_usefixtures_marker_on_unittest(base, testdir):
 | 
				
			||||||
    """#3498"""
 | 
					    """#3498"""
 | 
				
			||||||
    module = base.rsplit(".", 1)[0]
 | 
					    module = base.rsplit(".", 1)[0]
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										1
									
								
								tox.ini
								
								
								
								
							
							
						
						
									
										1
									
								
								tox.ini
								
								
								
								
							| 
						 | 
					@ -45,7 +45,6 @@ deps =
 | 
				
			||||||
    pexpect: pexpect
 | 
					    pexpect: pexpect
 | 
				
			||||||
    pluggymaster: git+https://github.com/pytest-dev/pluggy.git@master
 | 
					    pluggymaster: git+https://github.com/pytest-dev/pluggy.git@master
 | 
				
			||||||
    twisted: twisted
 | 
					    twisted: twisted
 | 
				
			||||||
    twisted: unittest2
 | 
					 | 
				
			||||||
    xdist: pytest-xdist>=1.13
 | 
					    xdist: pytest-xdist>=1.13
 | 
				
			||||||
    {env:_PYTEST_TOX_EXTRA_DEP:}
 | 
					    {env:_PYTEST_TOX_EXTRA_DEP:}
 | 
				
			||||||
platform = {env:_PYTEST_TOX_PLATFORM:.*}
 | 
					platform = {env:_PYTEST_TOX_PLATFORM:.*}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue