manual: remove dependence on six
This commit is contained in:
parent
ca1efd57bd
commit
5dcf85c17e
1
setup.py
1
setup.py
|
@ -4,7 +4,6 @@ from setuptools import setup
|
||||||
# remove _width_of_current_line in terminal.py
|
# remove _width_of_current_line in terminal.py
|
||||||
INSTALL_REQUIRES = [
|
INSTALL_REQUIRES = [
|
||||||
"py>=1.5.0",
|
"py>=1.5.0",
|
||||||
"six>=1.10.0",
|
|
||||||
"packaging",
|
"packaging",
|
||||||
"attrs>=17.4.0",
|
"attrs>=17.4.0",
|
||||||
"more-itertools>=4.0.0",
|
"more-itertools>=4.0.0",
|
||||||
|
|
|
@ -14,7 +14,6 @@ from importlib.util import spec_from_file_location
|
||||||
|
|
||||||
import atomicwrites
|
import atomicwrites
|
||||||
import py
|
import py
|
||||||
import six
|
|
||||||
|
|
||||||
from _pytest._io.saferepr import saferepr
|
from _pytest._io.saferepr import saferepr
|
||||||
from _pytest.assertion import util
|
from _pytest.assertion import util
|
||||||
|
@ -612,7 +611,7 @@ class AssertionRewriter(ast.NodeVisitor):
|
||||||
# Insert some special imports at the top of the module but after any
|
# Insert some special imports at the top of the module but after any
|
||||||
# docstrings and __future__ imports.
|
# docstrings and __future__ imports.
|
||||||
aliases = [
|
aliases = [
|
||||||
ast.alias(six.moves.builtins.__name__, "@py_builtins"),
|
ast.alias("builtins", "@py_builtins"),
|
||||||
ast.alias("_pytest.assertion.rewrite", "@pytest_ar"),
|
ast.alias("_pytest.assertion.rewrite", "@pytest_ar"),
|
||||||
]
|
]
|
||||||
doc = getattr(mod, "docstring", None)
|
doc = getattr(mod, "docstring", None)
|
||||||
|
|
|
@ -9,7 +9,6 @@ from collections import OrderedDict
|
||||||
|
|
||||||
import attr
|
import attr
|
||||||
import py
|
import py
|
||||||
import six
|
|
||||||
|
|
||||||
import _pytest
|
import _pytest
|
||||||
from _pytest import nodes
|
from _pytest import nodes
|
||||||
|
@ -848,10 +847,10 @@ class FixtureDef:
|
||||||
except: # noqa
|
except: # noqa
|
||||||
exceptions.append(sys.exc_info())
|
exceptions.append(sys.exc_info())
|
||||||
if exceptions:
|
if exceptions:
|
||||||
e = exceptions[0]
|
_, val, tb = exceptions[0]
|
||||||
# Ensure to not keep frame references through traceback.
|
# Ensure to not keep frame references through traceback.
|
||||||
del exceptions
|
del exceptions
|
||||||
six.reraise(*e)
|
raise val.with_traceback(tb)
|
||||||
finally:
|
finally:
|
||||||
hook = self._fixturemanager.session.gethookproxy(request.node.fspath)
|
hook = self._fixturemanager.session.gethookproxy(request.node.fspath)
|
||||||
hook.pytest_fixture_post_finalizer(fixturedef=self, request=request)
|
hook.pytest_fixture_post_finalizer(fixturedef=self, request=request)
|
||||||
|
@ -877,7 +876,8 @@ class FixtureDef:
|
||||||
result, cache_key, err = cached_result
|
result, cache_key, err = cached_result
|
||||||
if my_cache_key == cache_key:
|
if my_cache_key == cache_key:
|
||||||
if err is not None:
|
if err is not None:
|
||||||
six.reraise(*err)
|
_, val, tb = err
|
||||||
|
raise val.with_traceback(tb)
|
||||||
else:
|
else:
|
||||||
return result
|
return result
|
||||||
# we have a previous but differently parametrized fixture instance
|
# we have a previous but differently parametrized fixture instance
|
||||||
|
@ -950,7 +950,7 @@ def wrap_function_to_error_out_if_called_directly(function, fixture_marker):
|
||||||
name=fixture_marker.name or function.__name__
|
name=fixture_marker.name or function.__name__
|
||||||
)
|
)
|
||||||
|
|
||||||
@six.wraps(function)
|
@functools.wraps(function)
|
||||||
def result(*args, **kwargs):
|
def result(*args, **kwargs):
|
||||||
fail(message, pytrace=False)
|
fail(message, pytrace=False)
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ import re
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
|
|
||||||
import py
|
import py
|
||||||
import six
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from _pytest.compat import dummy_context_manager
|
from _pytest.compat import dummy_context_manager
|
||||||
|
@ -66,10 +65,7 @@ class ColoredLevelFormatter(logging.Formatter):
|
||||||
return super().format(record)
|
return super().format(record)
|
||||||
|
|
||||||
|
|
||||||
if not six.PY2:
|
class PercentStyleMultiline(logging.PercentStyle):
|
||||||
# Formatter classes don't support format styles in PY2
|
|
||||||
|
|
||||||
class PercentStyleMultiline(logging.PercentStyle):
|
|
||||||
"""A logging style with special support for multiline messages.
|
"""A logging style with special support for multiline messages.
|
||||||
|
|
||||||
If the message of a record consists of multiple lines, this style
|
If the message of a record consists of multiple lines, this style
|
||||||
|
@ -464,7 +460,6 @@ class LoggingPlugin:
|
||||||
else:
|
else:
|
||||||
formatter = logging.Formatter(log_format, log_date_format)
|
formatter = logging.Formatter(log_format, log_date_format)
|
||||||
|
|
||||||
if not six.PY2:
|
|
||||||
formatter._style = PercentStyleMultiline(formatter._style._fmt)
|
formatter._style = PercentStyleMultiline(formatter._style._fmt)
|
||||||
return formatter
|
return formatter
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@ import sys
|
||||||
from time import time
|
from time import time
|
||||||
|
|
||||||
import attr
|
import attr
|
||||||
import six
|
|
||||||
|
|
||||||
from .reports import CollectErrorRepr
|
from .reports import CollectErrorRepr
|
||||||
from .reports import CollectReport
|
from .reports import CollectReport
|
||||||
|
@ -304,7 +303,8 @@ class SetupState:
|
||||||
if exc is None:
|
if exc is None:
|
||||||
exc = sys.exc_info()
|
exc = sys.exc_info()
|
||||||
if exc:
|
if exc:
|
||||||
six.reraise(*exc)
|
_, val, tb = exc
|
||||||
|
raise val.with_traceback(tb)
|
||||||
|
|
||||||
def _teardown_with_finalization(self, colitem):
|
def _teardown_with_finalization(self, colitem):
|
||||||
self._callfinalizers(colitem)
|
self._callfinalizers(colitem)
|
||||||
|
@ -339,7 +339,8 @@ class SetupState:
|
||||||
if exc is None:
|
if exc is None:
|
||||||
exc = sys.exc_info()
|
exc = sys.exc_info()
|
||||||
if exc:
|
if exc:
|
||||||
six.reraise(*exc)
|
_, val, tb = exc
|
||||||
|
raise val.with_traceback(tb)
|
||||||
|
|
||||||
def prepare(self, colitem):
|
def prepare(self, colitem):
|
||||||
""" setup objects along the collector chain to the test-method
|
""" setup objects along the collector chain to the test-method
|
||||||
|
@ -350,7 +351,8 @@ class SetupState:
|
||||||
# check if the last collection node has raised an error
|
# check if the last collection node has raised an error
|
||||||
for col in self.stack:
|
for col in self.stack:
|
||||||
if hasattr(col, "_prepare_exc"):
|
if hasattr(col, "_prepare_exc"):
|
||||||
six.reraise(*col._prepare_exc)
|
_, val, tb = col._prepare_exc
|
||||||
|
raise val.with_traceback(tb)
|
||||||
for col in needed_collectors[len(self.stack) :]:
|
for col in needed_collectors[len(self.stack) :]:
|
||||||
self.stack.append(col)
|
self.stack.append(col)
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -5,8 +5,6 @@ import ast
|
||||||
import inspect
|
import inspect
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
import _pytest._code
|
import _pytest._code
|
||||||
import pytest
|
import pytest
|
||||||
from _pytest._code import Source
|
from _pytest._code import Source
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import py.io
|
import py.io
|
||||||
import six
|
|
||||||
|
|
||||||
import pytest
|
|
||||||
from _pytest.logging import ColoredLevelFormatter
|
from _pytest.logging import ColoredLevelFormatter
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,9 +36,6 @@ def test_coloredlogformatter():
|
||||||
assert output == ("dummypath 10 INFO Test Message")
|
assert output == ("dummypath 10 INFO Test Message")
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skipif(
|
|
||||||
six.PY2, reason="Formatter classes don't support format styles in PY2"
|
|
||||||
)
|
|
||||||
def test_multiline_message():
|
def test_multiline_message():
|
||||||
from _pytest.logging import PercentStyleMultiline
|
from _pytest.logging import PercentStyleMultiline
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
|
import io
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
|
@ -885,7 +884,7 @@ def test_live_logging_suspends_capture(has_capture_manager, request):
|
||||||
yield
|
yield
|
||||||
self.calls.append("exit disabled")
|
self.calls.append("exit disabled")
|
||||||
|
|
||||||
class DummyTerminal(six.StringIO):
|
class DummyTerminal(io.StringIO):
|
||||||
def section(self, *args, **kwargs):
|
def section(self, *args, **kwargs):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -1357,9 +1357,8 @@ class TestFixtureManagerParseFactories:
|
||||||
|
|
||||||
def test_parsefactories_conftest_and_module_and_class(self, testdir):
|
def test_parsefactories_conftest_and_module_and_class(self, testdir):
|
||||||
testdir.makepyfile(
|
testdir.makepyfile(
|
||||||
"""
|
"""\
|
||||||
import pytest
|
import pytest
|
||||||
import six
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def hello(request):
|
def hello(request):
|
||||||
|
|
|
@ -892,7 +892,7 @@ class TestMetafuncFunctional:
|
||||||
p = testdir.makepyfile(
|
p = testdir.makepyfile(
|
||||||
"""
|
"""
|
||||||
# assumes that generate/provide runs in the same process
|
# assumes that generate/provide runs in the same process
|
||||||
import sys, pytest, six
|
import sys, pytest
|
||||||
def pytest_generate_tests(metafunc):
|
def pytest_generate_tests(metafunc):
|
||||||
metafunc.parametrize('metafunc', [metafunc])
|
metafunc.parametrize('metafunc', [metafunc])
|
||||||
|
|
||||||
|
@ -910,7 +910,7 @@ class TestMetafuncFunctional:
|
||||||
def test_method(self, metafunc, pytestconfig):
|
def test_method(self, metafunc, pytestconfig):
|
||||||
assert metafunc.config == pytestconfig
|
assert metafunc.config == pytestconfig
|
||||||
assert metafunc.module.__name__ == __name__
|
assert metafunc.module.__name__ == __name__
|
||||||
unbound = six.get_unbound_function(TestClass.test_method)
|
unbound = TestClass.test_method
|
||||||
assert metafunc.function == unbound
|
assert metafunc.function == unbound
|
||||||
assert metafunc.cls == TestClass
|
assert metafunc.cls == TestClass
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -917,7 +917,7 @@ def test_class_method_containing_test_issue1558(testdir):
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"base", ["six.moves.builtins.object", "unittest.TestCase", "unittest2.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"""
|
||||||
|
|
Loading…
Reference in New Issue