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
|
||||
INSTALL_REQUIRES = [
|
||||
"py>=1.5.0",
|
||||
"six>=1.10.0",
|
||||
"packaging",
|
||||
"attrs>=17.4.0",
|
||||
"more-itertools>=4.0.0",
|
||||
|
|
|
@ -14,7 +14,6 @@ from importlib.util import spec_from_file_location
|
|||
|
||||
import atomicwrites
|
||||
import py
|
||||
import six
|
||||
|
||||
from _pytest._io.saferepr import saferepr
|
||||
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
|
||||
# docstrings and __future__ imports.
|
||||
aliases = [
|
||||
ast.alias(six.moves.builtins.__name__, "@py_builtins"),
|
||||
ast.alias("builtins", "@py_builtins"),
|
||||
ast.alias("_pytest.assertion.rewrite", "@pytest_ar"),
|
||||
]
|
||||
doc = getattr(mod, "docstring", None)
|
||||
|
|
|
@ -9,7 +9,6 @@ from collections import OrderedDict
|
|||
|
||||
import attr
|
||||
import py
|
||||
import six
|
||||
|
||||
import _pytest
|
||||
from _pytest import nodes
|
||||
|
@ -848,10 +847,10 @@ class FixtureDef:
|
|||
except: # noqa
|
||||
exceptions.append(sys.exc_info())
|
||||
if exceptions:
|
||||
e = exceptions[0]
|
||||
_, val, tb = exceptions[0]
|
||||
# Ensure to not keep frame references through traceback.
|
||||
del exceptions
|
||||
six.reraise(*e)
|
||||
raise val.with_traceback(tb)
|
||||
finally:
|
||||
hook = self._fixturemanager.session.gethookproxy(request.node.fspath)
|
||||
hook.pytest_fixture_post_finalizer(fixturedef=self, request=request)
|
||||
|
@ -877,7 +876,8 @@ class FixtureDef:
|
|||
result, cache_key, err = cached_result
|
||||
if my_cache_key == cache_key:
|
||||
if err is not None:
|
||||
six.reraise(*err)
|
||||
_, val, tb = err
|
||||
raise val.with_traceback(tb)
|
||||
else:
|
||||
return result
|
||||
# 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__
|
||||
)
|
||||
|
||||
@six.wraps(function)
|
||||
@functools.wraps(function)
|
||||
def result(*args, **kwargs):
|
||||
fail(message, pytrace=False)
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import re
|
|||
from contextlib import contextmanager
|
||||
|
||||
import py
|
||||
import six
|
||||
|
||||
import pytest
|
||||
from _pytest.compat import dummy_context_manager
|
||||
|
@ -66,9 +65,6 @@ class ColoredLevelFormatter(logging.Formatter):
|
|||
return super().format(record)
|
||||
|
||||
|
||||
if not six.PY2:
|
||||
# Formatter classes don't support format styles in PY2
|
||||
|
||||
class PercentStyleMultiline(logging.PercentStyle):
|
||||
"""A logging style with special support for multiline messages.
|
||||
|
||||
|
@ -464,7 +460,6 @@ class LoggingPlugin:
|
|||
else:
|
||||
formatter = logging.Formatter(log_format, log_date_format)
|
||||
|
||||
if not six.PY2:
|
||||
formatter._style = PercentStyleMultiline(formatter._style._fmt)
|
||||
return formatter
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ import sys
|
|||
from time import time
|
||||
|
||||
import attr
|
||||
import six
|
||||
|
||||
from .reports import CollectErrorRepr
|
||||
from .reports import CollectReport
|
||||
|
@ -304,7 +303,8 @@ class SetupState:
|
|||
if exc is None:
|
||||
exc = sys.exc_info()
|
||||
if exc:
|
||||
six.reraise(*exc)
|
||||
_, val, tb = exc
|
||||
raise val.with_traceback(tb)
|
||||
|
||||
def _teardown_with_finalization(self, colitem):
|
||||
self._callfinalizers(colitem)
|
||||
|
@ -339,7 +339,8 @@ class SetupState:
|
|||
if exc is None:
|
||||
exc = sys.exc_info()
|
||||
if exc:
|
||||
six.reraise(*exc)
|
||||
_, val, tb = exc
|
||||
raise val.with_traceback(tb)
|
||||
|
||||
def prepare(self, colitem):
|
||||
""" 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
|
||||
for col in self.stack:
|
||||
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) :]:
|
||||
self.stack.append(col)
|
||||
try:
|
||||
|
|
|
@ -5,8 +5,6 @@ import ast
|
|||
import inspect
|
||||
import sys
|
||||
|
||||
import six
|
||||
|
||||
import _pytest._code
|
||||
import pytest
|
||||
from _pytest._code import Source
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
import logging
|
||||
|
||||
import py.io
|
||||
import six
|
||||
|
||||
import pytest
|
||||
from _pytest.logging import ColoredLevelFormatter
|
||||
|
||||
|
||||
|
@ -38,9 +36,6 @@ def test_coloredlogformatter():
|
|||
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():
|
||||
from _pytest.logging import PercentStyleMultiline
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
import io
|
||||
import os
|
||||
import re
|
||||
|
||||
import six
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
|
@ -885,7 +884,7 @@ def test_live_logging_suspends_capture(has_capture_manager, request):
|
|||
yield
|
||||
self.calls.append("exit disabled")
|
||||
|
||||
class DummyTerminal(six.StringIO):
|
||||
class DummyTerminal(io.StringIO):
|
||||
def section(self, *args, **kwargs):
|
||||
pass
|
||||
|
||||
|
|
|
@ -1357,9 +1357,8 @@ class TestFixtureManagerParseFactories:
|
|||
|
||||
def test_parsefactories_conftest_and_module_and_class(self, testdir):
|
||||
testdir.makepyfile(
|
||||
"""
|
||||
"""\
|
||||
import pytest
|
||||
import six
|
||||
|
||||
@pytest.fixture
|
||||
def hello(request):
|
||||
|
|
|
@ -892,7 +892,7 @@ class TestMetafuncFunctional:
|
|||
p = testdir.makepyfile(
|
||||
"""
|
||||
# assumes that generate/provide runs in the same process
|
||||
import sys, pytest, six
|
||||
import sys, pytest
|
||||
def pytest_generate_tests(metafunc):
|
||||
metafunc.parametrize('metafunc', [metafunc])
|
||||
|
||||
|
@ -910,7 +910,7 @@ class TestMetafuncFunctional:
|
|||
def test_method(self, metafunc, pytestconfig):
|
||||
assert metafunc.config == pytestconfig
|
||||
assert metafunc.module.__name__ == __name__
|
||||
unbound = six.get_unbound_function(TestClass.test_method)
|
||||
unbound = TestClass.test_method
|
||||
assert metafunc.function == unbound
|
||||
assert metafunc.cls == TestClass
|
||||
"""
|
||||
|
|
|
@ -917,7 +917,7 @@ def test_class_method_containing_test_issue1558(testdir):
|
|||
|
||||
|
||||
@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):
|
||||
"""#3498"""
|
||||
|
|
Loading…
Reference in New Issue