convert py module references to six module
This commit is contained in:
parent
eb1bd3449e
commit
dc563e4954
|
@ -8,8 +8,6 @@ from _pytest.compat import _PY2, _PY3, PY35, safe_str
|
||||||
import py
|
import py
|
||||||
builtin_repr = repr
|
builtin_repr = repr
|
||||||
|
|
||||||
reprlib = py.builtin._tryimport('repr', 'reprlib')
|
|
||||||
|
|
||||||
if _PY3:
|
if _PY3:
|
||||||
from traceback import format_exception_only
|
from traceback import format_exception_only
|
||||||
else:
|
else:
|
||||||
|
@ -235,7 +233,7 @@ class TracebackEntry(object):
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if py.builtin.callable(tbh):
|
if callable(tbh):
|
||||||
return tbh(None if self._excinfo is None else self._excinfo())
|
return tbh(None if self._excinfo is None else self._excinfo())
|
||||||
else:
|
else:
|
||||||
return tbh
|
return tbh
|
||||||
|
|
|
@ -2,6 +2,7 @@ from __future__ import absolute_import, division, generators, print_function
|
||||||
|
|
||||||
from bisect import bisect_right
|
from bisect import bisect_right
|
||||||
import sys
|
import sys
|
||||||
|
import six
|
||||||
import inspect
|
import inspect
|
||||||
import tokenize
|
import tokenize
|
||||||
import py
|
import py
|
||||||
|
@ -32,7 +33,7 @@ class Source(object):
|
||||||
partlines = part.lines
|
partlines = part.lines
|
||||||
elif isinstance(part, (tuple, list)):
|
elif isinstance(part, (tuple, list)):
|
||||||
partlines = [x.rstrip("\n") for x in part]
|
partlines = [x.rstrip("\n") for x in part]
|
||||||
elif isinstance(part, py.builtin._basestring):
|
elif isinstance(part, six.string_types):
|
||||||
partlines = part.split('\n')
|
partlines = part.split('\n')
|
||||||
if rstrip:
|
if rstrip:
|
||||||
while partlines:
|
while partlines:
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
support for presenting detailed information in failing assertions.
|
support for presenting detailed information in failing assertions.
|
||||||
"""
|
"""
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function
|
||||||
import py
|
|
||||||
import sys
|
import sys
|
||||||
|
import six
|
||||||
|
|
||||||
from _pytest.assertion import util
|
from _pytest.assertion import util
|
||||||
from _pytest.assertion import rewrite
|
from _pytest.assertion import rewrite
|
||||||
|
@ -126,7 +126,7 @@ def pytest_runtest_setup(item):
|
||||||
if new_expl:
|
if new_expl:
|
||||||
new_expl = truncate.truncate_if_required(new_expl, item)
|
new_expl = truncate.truncate_if_required(new_expl, item)
|
||||||
new_expl = [line.replace("\n", "\\n") for line in new_expl]
|
new_expl = [line.replace("\n", "\\n") for line in new_expl]
|
||||||
res = py.builtin._totext("\n~").join(new_expl)
|
res = six.text_type("\n~").join(new_expl)
|
||||||
if item.config.getvalue("assertmode") == "rewrite":
|
if item.config.getvalue("assertmode") == "rewrite":
|
||||||
res = res.replace("%", "%%")
|
res = res.replace("%", "%%")
|
||||||
return res
|
return res
|
||||||
|
|
|
@ -8,6 +8,7 @@ import imp
|
||||||
import marshal
|
import marshal
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
import six
|
||||||
import struct
|
import struct
|
||||||
import sys
|
import sys
|
||||||
import types
|
import types
|
||||||
|
@ -405,10 +406,10 @@ def _saferepr(obj):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
repr = py.io.saferepr(obj)
|
repr = py.io.saferepr(obj)
|
||||||
if py.builtin._istext(repr):
|
if isinstance(repr, six.text_type):
|
||||||
t = py.builtin.text
|
t = six.text_type
|
||||||
else:
|
else:
|
||||||
t = py.builtin.bytes
|
t = six.binary_type
|
||||||
return repr.replace(t("\n"), t("\\n"))
|
return repr.replace(t("\n"), t("\\n"))
|
||||||
|
|
||||||
|
|
||||||
|
@ -427,16 +428,16 @@ def _format_assertmsg(obj):
|
||||||
# contains a newline it gets escaped, however if an object has a
|
# contains a newline it gets escaped, however if an object has a
|
||||||
# .__repr__() which contains newlines it does not get escaped.
|
# .__repr__() which contains newlines it does not get escaped.
|
||||||
# However in either case we want to preserve the newline.
|
# However in either case we want to preserve the newline.
|
||||||
if py.builtin._istext(obj) or py.builtin._isbytes(obj):
|
if isinstance(obj, six.text_type) or isinstance(obj, six.binary_type):
|
||||||
s = obj
|
s = obj
|
||||||
is_repr = False
|
is_repr = False
|
||||||
else:
|
else:
|
||||||
s = py.io.saferepr(obj)
|
s = py.io.saferepr(obj)
|
||||||
is_repr = True
|
is_repr = True
|
||||||
if py.builtin._istext(s):
|
if isinstance(s, six.text_type):
|
||||||
t = py.builtin.text
|
t = six.text_type
|
||||||
else:
|
else:
|
||||||
t = py.builtin.bytes
|
t = six.binary_type
|
||||||
s = s.replace(t("\n"), t("\n~")).replace(t("%"), t("%%"))
|
s = s.replace(t("\n"), t("\n~")).replace(t("%"), t("%%"))
|
||||||
if is_repr:
|
if is_repr:
|
||||||
s = s.replace(t("\\n"), t("\n~"))
|
s = s.replace(t("\\n"), t("\n~"))
|
||||||
|
@ -444,15 +445,15 @@ def _format_assertmsg(obj):
|
||||||
|
|
||||||
|
|
||||||
def _should_repr_global_name(obj):
|
def _should_repr_global_name(obj):
|
||||||
return not hasattr(obj, "__name__") and not py.builtin.callable(obj)
|
return not hasattr(obj, "__name__") and not callable(obj)
|
||||||
|
|
||||||
|
|
||||||
def _format_boolop(explanations, is_or):
|
def _format_boolop(explanations, is_or):
|
||||||
explanation = "(" + (is_or and " or " or " and ").join(explanations) + ")"
|
explanation = "(" + (is_or and " or " or " and ").join(explanations) + ")"
|
||||||
if py.builtin._istext(explanation):
|
if isinstance(explanation, six.text_type):
|
||||||
t = py.builtin.text
|
t = six.text_type
|
||||||
else:
|
else:
|
||||||
t = py.builtin.bytes
|
t = six.binary_type
|
||||||
return explanation.replace(t('%'), t('%%'))
|
return explanation.replace(t('%'), t('%%'))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ Current default behaviour is to truncate assertion explanations at
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import py
|
import six
|
||||||
|
|
||||||
|
|
||||||
DEFAULT_MAX_LINES = 8
|
DEFAULT_MAX_LINES = 8
|
||||||
|
@ -74,8 +74,8 @@ def _truncate_explanation(input_lines, max_lines=None, max_chars=None):
|
||||||
msg += ' ({0} lines hidden)'.format(truncated_line_count)
|
msg += ' ({0} lines hidden)'.format(truncated_line_count)
|
||||||
msg += ", {0}" .format(USAGE_MSG)
|
msg += ", {0}" .format(USAGE_MSG)
|
||||||
truncated_explanation.extend([
|
truncated_explanation.extend([
|
||||||
py.builtin._totext(""),
|
six.text_type(""),
|
||||||
py.builtin._totext(msg),
|
six.text_type(msg),
|
||||||
])
|
])
|
||||||
return truncated_explanation
|
return truncated_explanation
|
||||||
|
|
||||||
|
|
|
@ -4,13 +4,14 @@ import pprint
|
||||||
|
|
||||||
import _pytest._code
|
import _pytest._code
|
||||||
import py
|
import py
|
||||||
|
import six
|
||||||
try:
|
try:
|
||||||
from collections import Sequence
|
from collections import Sequence
|
||||||
except ImportError:
|
except ImportError:
|
||||||
Sequence = list
|
Sequence = list
|
||||||
|
|
||||||
|
|
||||||
u = py.builtin._totext
|
u = six.text_type
|
||||||
|
|
||||||
# The _reprcompare attribute on the util module is used by the new assertion
|
# The _reprcompare attribute on the util module is used by the new assertion
|
||||||
# interpretation code and assertion rewriter to detect this plugin was
|
# interpretation code and assertion rewriter to detect this plugin was
|
||||||
|
@ -174,9 +175,9 @@ def _diff_text(left, right, verbose=False):
|
||||||
"""
|
"""
|
||||||
from difflib import ndiff
|
from difflib import ndiff
|
||||||
explanation = []
|
explanation = []
|
||||||
if isinstance(left, py.builtin.bytes):
|
if isinstance(left, six.binary_type):
|
||||||
left = u(repr(left)[1:-1]).replace(r'\n', '\n')
|
left = u(repr(left)[1:-1]).replace(r'\n', '\n')
|
||||||
if isinstance(right, py.builtin.bytes):
|
if isinstance(right, six.binary_type):
|
||||||
right = u(repr(right)[1:-1]).replace(r'\n', '\n')
|
right = u(repr(right)[1:-1]).replace(r'\n', '\n')
|
||||||
if not verbose:
|
if not verbose:
|
||||||
i = 0 # just in case left or right has zero length
|
i = 0 # just in case left or right has zero length
|
||||||
|
|
|
@ -11,11 +11,10 @@ import io
|
||||||
from io import UnsupportedOperation
|
from io import UnsupportedOperation
|
||||||
from tempfile import TemporaryFile
|
from tempfile import TemporaryFile
|
||||||
|
|
||||||
import py
|
import six
|
||||||
import pytest
|
import pytest
|
||||||
from _pytest.compat import CaptureIO
|
from _pytest.compat import CaptureIO
|
||||||
|
|
||||||
unicode = py.builtin.text
|
|
||||||
|
|
||||||
patchsysdict = {0: 'stdin', 1: 'stdout', 2: 'stderr'}
|
patchsysdict = {0: 'stdin', 1: 'stdout', 2: 'stderr'}
|
||||||
|
|
||||||
|
@ -246,7 +245,7 @@ class EncodedFile(object):
|
||||||
self.encoding = encoding
|
self.encoding = encoding
|
||||||
|
|
||||||
def write(self, obj):
|
def write(self, obj):
|
||||||
if isinstance(obj, unicode):
|
if isinstance(obj, six.text_type):
|
||||||
obj = obj.encode(self.encoding, "replace")
|
obj = obj.encode(self.encoding, "replace")
|
||||||
self.buffer.write(obj)
|
self.buffer.write(obj)
|
||||||
|
|
||||||
|
@ -377,7 +376,7 @@ class FDCapture:
|
||||||
if res:
|
if res:
|
||||||
enc = getattr(f, "encoding", None)
|
enc = getattr(f, "encoding", None)
|
||||||
if enc and isinstance(res, bytes):
|
if enc and isinstance(res, bytes):
|
||||||
res = py.builtin._totext(res, enc, "replace")
|
res = six.text_type(res, enc, "replace")
|
||||||
f.truncate(0)
|
f.truncate(0)
|
||||||
f.seek(0)
|
f.seek(0)
|
||||||
return res
|
return res
|
||||||
|
@ -402,7 +401,7 @@ class FDCapture:
|
||||||
|
|
||||||
def writeorg(self, data):
|
def writeorg(self, data):
|
||||||
""" write to original file descriptor. """
|
""" write to original file descriptor. """
|
||||||
if py.builtin._istext(data):
|
if isinstance(data, six.text_type):
|
||||||
data = data.encode("utf8") # XXX use encoding of original stream
|
data = data.encode("utf8") # XXX use encoding of original stream
|
||||||
os.write(self.targetfd_save, data)
|
os.write(self.targetfd_save, data)
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import traceback
|
||||||
import types
|
import types
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
|
import six
|
||||||
import py
|
import py
|
||||||
# DON't import pytest here because it causes import cycle troubles
|
# DON't import pytest here because it causes import cycle troubles
|
||||||
import sys
|
import sys
|
||||||
|
@ -158,7 +159,7 @@ def _prepareconfig(args=None, plugins=None):
|
||||||
try:
|
try:
|
||||||
if plugins:
|
if plugins:
|
||||||
for plugin in plugins:
|
for plugin in plugins:
|
||||||
if isinstance(plugin, py.builtin._basestring):
|
if isinstance(plugin, six.string_types):
|
||||||
pluginmanager.consider_pluginarg(plugin)
|
pluginmanager.consider_pluginarg(plugin)
|
||||||
else:
|
else:
|
||||||
pluginmanager.register(plugin)
|
pluginmanager.register(plugin)
|
||||||
|
@ -430,7 +431,7 @@ class PytestPluginManager(PluginManager):
|
||||||
# "terminal" or "capture". Those plugins are registered under their
|
# "terminal" or "capture". Those plugins are registered under their
|
||||||
# basename for historic purposes but must be imported with the
|
# basename for historic purposes but must be imported with the
|
||||||
# _pytest prefix.
|
# _pytest prefix.
|
||||||
assert isinstance(modname, (py.builtin.text, str)), "module name as text required, got %r" % modname
|
assert isinstance(modname, (six.text_type, str)), "module name as text required, got %r" % modname
|
||||||
modname = str(modname)
|
modname = str(modname)
|
||||||
if self.get_plugin(modname) is not None:
|
if self.get_plugin(modname) is not None:
|
||||||
return
|
return
|
||||||
|
@ -643,7 +644,7 @@ class Argument:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
# this might raise a keyerror as well, don't want to catch that
|
# this might raise a keyerror as well, don't want to catch that
|
||||||
if isinstance(typ, py.builtin._basestring):
|
if isinstance(typ, six.string_types):
|
||||||
if typ == 'choice':
|
if typ == 'choice':
|
||||||
warnings.warn(
|
warnings.warn(
|
||||||
'type argument to addoption() is a string %r.'
|
'type argument to addoption() is a string %r.'
|
||||||
|
@ -956,7 +957,7 @@ class Config(object):
|
||||||
)
|
)
|
||||||
res = self.hook.pytest_internalerror(excrepr=excrepr,
|
res = self.hook.pytest_internalerror(excrepr=excrepr,
|
||||||
excinfo=excinfo)
|
excinfo=excinfo)
|
||||||
if not py.builtin.any(res):
|
if not any(res):
|
||||||
for line in str(excrepr).split("\n"):
|
for line in str(excrepr).split("\n"):
|
||||||
sys.stderr.write("INTERNALERROR> %s\n" % line)
|
sys.stderr.write("INTERNALERROR> %s\n" % line)
|
||||||
sys.stderr.flush()
|
sys.stderr.flush()
|
||||||
|
|
|
@ -3,6 +3,7 @@ from __future__ import absolute_import, division, print_function
|
||||||
|
|
||||||
import functools
|
import functools
|
||||||
import os
|
import os
|
||||||
|
import six
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import _pytest
|
import _pytest
|
||||||
|
@ -397,7 +398,7 @@ class Node(object):
|
||||||
``marker`` can be a string or pytest.mark.* instance.
|
``marker`` can be a string or pytest.mark.* instance.
|
||||||
"""
|
"""
|
||||||
from _pytest.mark import MarkDecorator, MARK_GEN
|
from _pytest.mark import MarkDecorator, MARK_GEN
|
||||||
if isinstance(marker, py.builtin._basestring):
|
if isinstance(marker, six.string_types):
|
||||||
marker = getattr(MARK_GEN, marker)
|
marker = getattr(MARK_GEN, marker)
|
||||||
elif not isinstance(marker, MarkDecorator):
|
elif not isinstance(marker, MarkDecorator):
|
||||||
raise ValueError("is not a string or pytest.mark.* Marker")
|
raise ValueError("is not a string or pytest.mark.* Marker")
|
||||||
|
|
|
@ -4,8 +4,7 @@ from __future__ import absolute_import, division, print_function
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
|
import six
|
||||||
from py.builtin import _basestring
|
|
||||||
from _pytest.fixtures import fixture
|
from _pytest.fixtures import fixture
|
||||||
|
|
||||||
RE_IMPORT_ERROR_NAME = re.compile("^No module named (.*)$")
|
RE_IMPORT_ERROR_NAME = re.compile("^No module named (.*)$")
|
||||||
|
@ -79,7 +78,7 @@ def annotated_getattr(obj, name, ann):
|
||||||
|
|
||||||
|
|
||||||
def derive_importpath(import_path, raising):
|
def derive_importpath(import_path, raising):
|
||||||
if not isinstance(import_path, _basestring) or "." not in import_path:
|
if not isinstance(import_path, six.string_types) or "." not in import_path:
|
||||||
raise TypeError("must be absolute import path string, not %r" %
|
raise TypeError("must be absolute import path string, not %r" %
|
||||||
(import_path,))
|
(import_path,))
|
||||||
module, attr = import_path.rsplit('.', 1)
|
module, attr = import_path.rsplit('.', 1)
|
||||||
|
@ -125,7 +124,7 @@ class MonkeyPatch:
|
||||||
import inspect
|
import inspect
|
||||||
|
|
||||||
if value is notset:
|
if value is notset:
|
||||||
if not isinstance(target, _basestring):
|
if not isinstance(target, six.string_types):
|
||||||
raise TypeError("use setattr(target, name, value) or "
|
raise TypeError("use setattr(target, name, value) or "
|
||||||
"setattr(target, value) with target being a dotted "
|
"setattr(target, value) with target being a dotted "
|
||||||
"import string")
|
"import string")
|
||||||
|
@ -155,7 +154,7 @@ class MonkeyPatch:
|
||||||
"""
|
"""
|
||||||
__tracebackhide__ = True
|
__tracebackhide__ = True
|
||||||
if name is notset:
|
if name is notset:
|
||||||
if not isinstance(target, _basestring):
|
if not isinstance(target, six.string_types):
|
||||||
raise TypeError("use delattr(target, name) or "
|
raise TypeError("use delattr(target, name) or "
|
||||||
"delattr(target) with target being a dotted "
|
"delattr(target) with target being a dotted "
|
||||||
"import string")
|
"import string")
|
||||||
|
|
|
@ -3,7 +3,6 @@ from __future__ import absolute_import, division, print_function
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import py
|
|
||||||
from _pytest import unittest, runner, python
|
from _pytest import unittest, runner, python
|
||||||
from _pytest.config import hookimpl
|
from _pytest.config import hookimpl
|
||||||
|
|
||||||
|
@ -66,7 +65,7 @@ def is_potential_nosetest(item):
|
||||||
def call_optional(obj, name):
|
def call_optional(obj, name):
|
||||||
method = getattr(obj, name, None)
|
method = getattr(obj, name, None)
|
||||||
isfixture = hasattr(method, "_pytestfixturefunction")
|
isfixture = hasattr(method, "_pytestfixturefunction")
|
||||||
if method is not None and not isfixture and py.builtin.callable(method):
|
if method is not None and not isfixture and callable(method):
|
||||||
# If there's any problems allow the exception to raise rather than
|
# If there's any problems allow the exception to raise rather than
|
||||||
# silently ignoring them
|
# silently ignoring them
|
||||||
method()
|
method()
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
import six
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
|
@ -16,7 +17,6 @@ def pytest_addoption(parser):
|
||||||
|
|
||||||
@pytest.hookimpl(trylast=True)
|
@pytest.hookimpl(trylast=True)
|
||||||
def pytest_configure(config):
|
def pytest_configure(config):
|
||||||
import py
|
|
||||||
if config.option.pastebin == "all":
|
if config.option.pastebin == "all":
|
||||||
tr = config.pluginmanager.getplugin('terminalreporter')
|
tr = config.pluginmanager.getplugin('terminalreporter')
|
||||||
# if no terminal reporter plugin is present, nothing we can do here;
|
# if no terminal reporter plugin is present, nothing we can do here;
|
||||||
|
@ -29,7 +29,7 @@ def pytest_configure(config):
|
||||||
|
|
||||||
def tee_write(s, **kwargs):
|
def tee_write(s, **kwargs):
|
||||||
oldwrite(s, **kwargs)
|
oldwrite(s, **kwargs)
|
||||||
if py.builtin._istext(s):
|
if isinstance(s, six.text_type):
|
||||||
s = s.encode('utf-8')
|
s = s.encode('utf-8')
|
||||||
config._pastebinfile.write(s)
|
config._pastebinfile.write(s)
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import os
|
||||||
import platform
|
import platform
|
||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import six
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
|
@ -485,8 +486,8 @@ class Testdir:
|
||||||
def _makefile(self, ext, args, kwargs, encoding="utf-8"):
|
def _makefile(self, ext, args, kwargs, encoding="utf-8"):
|
||||||
items = list(kwargs.items())
|
items = list(kwargs.items())
|
||||||
if args:
|
if args:
|
||||||
source = py.builtin._totext("\n").join(
|
source = six.text_type("\n").join(
|
||||||
map(py.builtin._totext, args)) + py.builtin._totext("\n")
|
map(six.text_type, args)) + six.text_type("\n")
|
||||||
basename = self.request.function.__name__
|
basename = self.request.function.__name__
|
||||||
items.insert(0, (basename, source))
|
items.insert(0, (basename, source))
|
||||||
ret = None
|
ret = None
|
||||||
|
@ -496,12 +497,12 @@ class Testdir:
|
||||||
source = Source(value)
|
source = Source(value)
|
||||||
|
|
||||||
def my_totext(s, encoding="utf-8"):
|
def my_totext(s, encoding="utf-8"):
|
||||||
if py.builtin._isbytes(s):
|
if isinstance(s, six.binary_type):
|
||||||
s = py.builtin._totext(s, encoding=encoding)
|
s = six.text_type(s, encoding=encoding)
|
||||||
return s
|
return s
|
||||||
|
|
||||||
source_unicode = "\n".join([my_totext(line) for line in source.lines])
|
source_unicode = "\n".join([my_totext(line) for line in source.lines])
|
||||||
source = py.builtin._totext(source_unicode)
|
source = six.text_type(source_unicode)
|
||||||
content = source.strip().encode(encoding) # + "\n"
|
content = source.strip().encode(encoding) # + "\n"
|
||||||
# content = content.rstrip() + "\n"
|
# content = content.rstrip() + "\n"
|
||||||
p.write(content, "wb")
|
p.write(content, "wb")
|
||||||
|
|
|
@ -10,6 +10,7 @@ from textwrap import dedent
|
||||||
from itertools import count
|
from itertools import count
|
||||||
|
|
||||||
import py
|
import py
|
||||||
|
import six
|
||||||
from _pytest.mark import MarkerError
|
from _pytest.mark import MarkerError
|
||||||
from _pytest.config import hookimpl
|
from _pytest.config import hookimpl
|
||||||
|
|
||||||
|
@ -613,7 +614,7 @@ class Generator(FunctionMixin, PyCollector):
|
||||||
if not isinstance(obj, (tuple, list)):
|
if not isinstance(obj, (tuple, list)):
|
||||||
obj = (obj,)
|
obj = (obj,)
|
||||||
# explicit naming
|
# explicit naming
|
||||||
if isinstance(obj[0], py.builtin._basestring):
|
if isinstance(obj[0], six.string_types):
|
||||||
name = obj[0]
|
name = obj[0]
|
||||||
obj = obj[1:]
|
obj = obj[1:]
|
||||||
else:
|
else:
|
||||||
|
@ -725,7 +726,7 @@ class Metafunc(fixtures.FuncargnamesCompatAttr):
|
||||||
self.cls = cls
|
self.cls = cls
|
||||||
|
|
||||||
self._calls = []
|
self._calls = []
|
||||||
self._ids = py.builtin.set()
|
self._ids = set()
|
||||||
self._arg2fixturedefs = fixtureinfo.name2fixturedefs
|
self._arg2fixturedefs = fixtureinfo.name2fixturedefs
|
||||||
|
|
||||||
def parametrize(self, argnames, argvalues, indirect=False, ids=None,
|
def parametrize(self, argnames, argvalues, indirect=False, ids=None,
|
||||||
|
@ -827,7 +828,7 @@ class Metafunc(fixtures.FuncargnamesCompatAttr):
|
||||||
raise ValueError('%d tests specified with %d ids' % (
|
raise ValueError('%d tests specified with %d ids' % (
|
||||||
len(parameters), len(ids)))
|
len(parameters), len(ids)))
|
||||||
for id_value in ids:
|
for id_value in ids:
|
||||||
if id_value is not None and not isinstance(id_value, py.builtin._basestring):
|
if id_value is not None and not isinstance(id_value, six.string_types):
|
||||||
msg = 'ids must be list of strings, found: %s (type: %s)'
|
msg = 'ids must be list of strings, found: %s (type: %s)'
|
||||||
raise ValueError(msg % (saferepr(id_value), type(id_value).__name__))
|
raise ValueError(msg % (saferepr(id_value), type(id_value).__name__))
|
||||||
ids = idmaker(argnames, parameters, idfn, ids, self.config)
|
ids = idmaker(argnames, parameters, idfn, ids, self.config)
|
||||||
|
|
|
@ -430,7 +430,7 @@ class SetupState(object):
|
||||||
is called at the end of teardown_all().
|
is called at the end of teardown_all().
|
||||||
"""
|
"""
|
||||||
assert colitem and not isinstance(colitem, tuple)
|
assert colitem and not isinstance(colitem, tuple)
|
||||||
assert py.builtin.callable(finalizer)
|
assert callable(finalizer)
|
||||||
# assert colitem in self.stack # some unit tests don't setup stack :/
|
# assert colitem in self.stack # some unit tests don't setup stack :/
|
||||||
self._finalizers.setdefault(colitem, []).append(finalizer)
|
self._finalizers.setdefault(colitem, []).append(finalizer)
|
||||||
|
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import six
|
||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
import py
|
|
||||||
from _pytest.config import hookimpl
|
from _pytest.config import hookimpl
|
||||||
from _pytest.mark import MarkInfo, MarkDecorator
|
from _pytest.mark import MarkInfo, MarkDecorator
|
||||||
from _pytest.runner import fail, skip
|
from _pytest.runner import fail, skip
|
||||||
|
@ -133,7 +133,7 @@ class MarkEvaluator:
|
||||||
args = (kwargs['condition'],)
|
args = (kwargs['condition'],)
|
||||||
for expr in args:
|
for expr in args:
|
||||||
self.expr = expr
|
self.expr = expr
|
||||||
if isinstance(expr, py.builtin._basestring):
|
if isinstance(expr, six.string_types):
|
||||||
d = self._getglobals()
|
d = self._getglobals()
|
||||||
result = cached_eval(self.item.config, expr, d)
|
result = cached_eval(self.item.config, expr, d)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -9,6 +9,7 @@ from _pytest.main import EXIT_OK, EXIT_TESTSFAILED, EXIT_INTERRUPTED, \
|
||||||
EXIT_USAGEERROR, EXIT_NOTESTSCOLLECTED
|
EXIT_USAGEERROR, EXIT_NOTESTSCOLLECTED
|
||||||
import pytest
|
import pytest
|
||||||
import py
|
import py
|
||||||
|
import six
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import platform
|
import platform
|
||||||
|
@ -174,8 +175,8 @@ class TerminalReporter:
|
||||||
self._tw.write(content, **markup)
|
self._tw.write(content, **markup)
|
||||||
|
|
||||||
def write_line(self, line, **markup):
|
def write_line(self, line, **markup):
|
||||||
if not py.builtin._istext(line):
|
if not isinstance(line, six.text_type):
|
||||||
line = py.builtin.text(line, errors="replace")
|
line = six.text_type(line, errors="replace")
|
||||||
self.ensure_newline()
|
self.ensure_newline()
|
||||||
self._tw.line(line, **markup)
|
self._tw.line(line, **markup)
|
||||||
|
|
||||||
|
@ -194,7 +195,7 @@ class TerminalReporter:
|
||||||
self._tw.line(msg, **kw)
|
self._tw.line(msg, **kw)
|
||||||
|
|
||||||
def pytest_internalerror(self, excrepr):
|
def pytest_internalerror(self, excrepr):
|
||||||
for line in py.builtin.text(excrepr).split("\n"):
|
for line in six.text_type(excrepr).split("\n"):
|
||||||
self.write_line("INTERNALERROR> " + line)
|
self.write_line("INTERNALERROR> " + line)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -43,7 +43,7 @@ def has_environment_marker_support():
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
install_requires = ['py>=1.4.33', 'setuptools'] # pluggy is vendored in _pytest.vendored_packages
|
install_requires = ['py>=1.4.33', 'six>=1.10.0','setuptools'] # pluggy is vendored in _pytest.vendored_packages
|
||||||
extras_require = {}
|
extras_require = {}
|
||||||
if has_environment_marker_support():
|
if has_environment_marker_support():
|
||||||
extras_require[':python_version=="2.6"'] = ['argparse']
|
extras_require[':python_version=="2.6"'] = ['argparse']
|
||||||
|
|
Loading…
Reference in New Issue