[Pytest-commit] commit/pytest: 3 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Thu Aug 7 10:34:04 CEST 2014
3 new commits in pytest:
https://bitbucket.org/hpk42/pytest/commits/fd0377e5a7ec/
Changeset: fd0377e5a7ec
User: flub
Date: 2014-08-01 01:29:35
Summary: Simply show the node ID for verbose output
This strips the line number, /@\d/, from the verbose output so it is
directly the node ID of the test. This in turn means no special logic
for accepting the line number as part of the node ID is needed when
parsing the command line.
Affected #: 6 files
diff -r 040c46f257331f1c4546246683a808668969c011 -r fd0377e5a7ecbc1a0b09f7f2389f9f0be2254d90 _pytest/config.py
--- a/_pytest/config.py
+++ b/_pytest/config.py
@@ -2,7 +2,6 @@
import py
# DON't import pytest here because it causes import cycle troubles
-import re
import sys, os
from _pytest import hookspec # the extension point definitions
from _pytest.core import PluginManager
@@ -181,8 +180,7 @@
a = option.attrs()
arggroup.add_argument(*n, **a)
# bash like autocompletion for dirs (appending '/')
- optparser.add_argument(FILE_OR_DIR, nargs='*', type=node_with_line_number,
- ).completer=filescompleter
+ optparser.add_argument(FILE_OR_DIR, nargs='*').completer=filescompleter
return optparser
def parse_setoption(self, args, option):
@@ -862,13 +860,6 @@
return {}
-rex_pyat = re.compile(r'(.*\.py)@\d+$')
-
-def node_with_line_number(string):
- return "::".join(rex_pyat.sub(lambda m: m.group(1), part)
- for part in string.split("::"))
-
-
def setns(obj, dic):
import pytest
for name, value in dic.items():
diff -r 040c46f257331f1c4546246683a808668969c011 -r fd0377e5a7ecbc1a0b09f7f2389f9f0be2254d90 _pytest/terminal.py
--- a/_pytest/terminal.py
+++ b/_pytest/terminal.py
@@ -380,9 +380,6 @@
fspath = "%s <- %s" % (collect_fspath, fspath)
if fspath:
line = str(fspath)
- if lineno is not None:
- lineno += 1
- line += "@" + str(lineno)
if domain:
split = str(domain).split('[')
split[0] = split[0].replace('.', '::') # don't replace '.' in params
diff -r 040c46f257331f1c4546246683a808668969c011 -r fd0377e5a7ecbc1a0b09f7f2389f9f0be2254d90 testing/python/fixture.py
--- a/testing/python/fixture.py
+++ b/testing/python/fixture.py
@@ -1692,22 +1692,22 @@
""")
result = testdir.runpytest("-v")
result.stdout.fnmatch_lines("""
- test_mod1.py at 1::test_func[s1] PASSED
- test_mod2.py at 1::test_func2[s1] PASSED
- test_mod2.py at 3::test_func3[s1-m1] PASSED
- test_mod2.py at 5::test_func3b[s1-m1] PASSED
- test_mod2.py at 3::test_func3[s1-m2] PASSED
- test_mod2.py at 5::test_func3b[s1-m2] PASSED
- test_mod1.py at 1::test_func[s2] PASSED
- test_mod2.py at 1::test_func2[s2] PASSED
- test_mod2.py at 3::test_func3[s2-m1] PASSED
- test_mod2.py at 5::test_func3b[s2-m1] PASSED
- test_mod2.py at 7::test_func4[m1] PASSED
- test_mod2.py at 3::test_func3[s2-m2] PASSED
- test_mod2.py at 5::test_func3b[s2-m2] PASSED
- test_mod2.py at 7::test_func4[m2] PASSED
- test_mod1.py at 3::test_func1[m1] PASSED
- test_mod1.py at 3::test_func1[m2] PASSED
+ test_mod1.py::test_func[s1] PASSED
+ test_mod2.py::test_func2[s1] PASSED
+ test_mod2.py::test_func3[s1-m1] PASSED
+ test_mod2.py::test_func3b[s1-m1] PASSED
+ test_mod2.py::test_func3[s1-m2] PASSED
+ test_mod2.py::test_func3b[s1-m2] PASSED
+ test_mod1.py::test_func[s2] PASSED
+ test_mod2.py::test_func2[s2] PASSED
+ test_mod2.py::test_func3[s2-m1] PASSED
+ test_mod2.py::test_func3b[s2-m1] PASSED
+ test_mod2.py::test_func4[m1] PASSED
+ test_mod2.py::test_func3[s2-m2] PASSED
+ test_mod2.py::test_func3b[s2-m2] PASSED
+ test_mod2.py::test_func4[m2] PASSED
+ test_mod1.py::test_func1[m1] PASSED
+ test_mod1.py::test_func1[m2] PASSED
""")
def test_class_ordering(self, testdir):
@@ -1744,18 +1744,18 @@
""")
result = testdir.runpytest("-vs")
result.stdout.fnmatch_lines("""
- test_class_ordering.py at 4::TestClass2::test_1[1-a] PASSED
- test_class_ordering.py at 4::TestClass2::test_1[2-a] PASSED
- test_class_ordering.py at 6::TestClass2::test_2[1-a] PASSED
- test_class_ordering.py at 6::TestClass2::test_2[2-a] PASSED
- test_class_ordering.py at 4::TestClass2::test_1[1-b] PASSED
- test_class_ordering.py at 4::TestClass2::test_1[2-b] PASSED
- test_class_ordering.py at 6::TestClass2::test_2[1-b] PASSED
- test_class_ordering.py at 6::TestClass2::test_2[2-b] PASSED
- test_class_ordering.py at 9::TestClass::test_3[1-a] PASSED
- test_class_ordering.py at 9::TestClass::test_3[2-a] PASSED
- test_class_ordering.py at 9::TestClass::test_3[1-b] PASSED
- test_class_ordering.py at 9::TestClass::test_3[2-b] PASSED
+ test_class_ordering.py::TestClass2::test_1[1-a] PASSED
+ test_class_ordering.py::TestClass2::test_1[2-a] PASSED
+ test_class_ordering.py::TestClass2::test_2[1-a] PASSED
+ test_class_ordering.py::TestClass2::test_2[2-a] PASSED
+ test_class_ordering.py::TestClass2::test_1[1-b] PASSED
+ test_class_ordering.py::TestClass2::test_1[2-b] PASSED
+ test_class_ordering.py::TestClass2::test_2[1-b] PASSED
+ test_class_ordering.py::TestClass2::test_2[2-b] PASSED
+ test_class_ordering.py::TestClass::test_3[1-a] PASSED
+ test_class_ordering.py::TestClass::test_3[2-a] PASSED
+ test_class_ordering.py::TestClass::test_3[1-b] PASSED
+ test_class_ordering.py::TestClass::test_3[2-b] PASSED
""")
def test_parametrize_separated_order_higher_scope_first(self, testdir):
diff -r 040c46f257331f1c4546246683a808668969c011 -r fd0377e5a7ecbc1a0b09f7f2389f9f0be2254d90 testing/test_conftest.py
--- a/testing/test_conftest.py
+++ b/testing/test_conftest.py
@@ -251,7 +251,7 @@
def test_hello(found):
assert found == 1
"""))
- result = testdir.runpytest(str(p) + "@2::test_hello", "-h")
+ result = testdir.runpytest(str(p) + "::test_hello", "-h")
result.stdout.fnmatch_lines("""
*--hello-world*
""")
diff -r 040c46f257331f1c4546246683a808668969c011 -r fd0377e5a7ecbc1a0b09f7f2389f9f0be2254d90 testing/test_parseopt.py
--- a/testing/test_parseopt.py
+++ b/testing/test_parseopt.py
@@ -145,21 +145,6 @@
assert args.R == True
assert args.S == False
- def test_parse_removes_line_number_from_positional_arguments(self, parser):
- args = parser.parse(['path.txt at 2::item',
- 'path2.py::func2[param with .py at 123]',
- 'path.py at 123',
- 'hello/path.py at 123',
- ])
- # we only remove "@NUM" syntax for .py files which are currently
- # the only ones which can produce it.
- assert getattr(args, parseopt.FILE_OR_DIR) == [
- 'path.txt at 2::item',
- 'path2.py::func2[param with .py at 123]',
- 'path.py',
- 'hello/path.py',
- ]
-
def test_parse_defaultgetter(self):
def defaultget(option):
if not hasattr(option, 'type'):
diff -r 040c46f257331f1c4546246683a808668969c011 -r fd0377e5a7ecbc1a0b09f7f2389f9f0be2254d90 testing/test_terminal.py
--- a/testing/test_terminal.py
+++ b/testing/test_terminal.py
@@ -51,9 +51,9 @@
result = testdir.runpytest(*option.args)
if option.verbose:
result.stdout.fnmatch_lines([
- "*test_pass_skip_fail.py at 2::test_ok PASS*",
- "*test_pass_skip_fail.py at 4::test_skip SKIP*",
- "*test_pass_skip_fail.py at 6::test_func FAIL*",
+ "*test_pass_skip_fail.py::test_ok PASS*",
+ "*test_pass_skip_fail.py::test_skip SKIP*",
+ "*test_pass_skip_fail.py::test_func FAIL*",
])
else:
result.stdout.fnmatch_lines([
@@ -126,7 +126,7 @@
])
result = testdir.runpytest("-v", p2)
result.stdout.fnmatch_lines([
- "*test_p2.py <- *test_p1.py at 2::TestMore::test_p1*",
+ "*test_p2.py <- *test_p1.py::TestMore::test_p1*",
])
def test_itemreport_directclasses_not_shown_as_subclasses(self, testdir):
@@ -450,17 +450,17 @@
""")
result = testdir.runpytest(p1, '-v')
result.stdout.fnmatch_lines([
- "*test_verbose_reporting.py at 2::test_fail *FAIL*",
- "*test_verbose_reporting.py at 4::test_pass *PASS*",
- "*test_verbose_reporting.py at 7::TestClass::test_skip *SKIP*",
- "*test_verbose_reporting.py at 10::test_gen*0* *FAIL*",
+ "*test_verbose_reporting.py::test_fail *FAIL*",
+ "*test_verbose_reporting.py::test_pass *PASS*",
+ "*test_verbose_reporting.py::TestClass::test_skip *SKIP*",
+ "*test_verbose_reporting.py::test_gen*0* *FAIL*",
])
assert result.ret == 1
pytestconfig.pluginmanager.skipifmissing("xdist")
result = testdir.runpytest(p1, '-v', '-n 1')
result.stdout.fnmatch_lines([
- "*FAIL*test_verbose_reporting.py at 2::test_fail*",
+ "*FAIL*test_verbose_reporting.py::test_fail*",
])
assert result.ret == 1
https://bitbucket.org/hpk42/pytest/commits/8007f98027d6/
Changeset: 8007f98027d6
User: flub
Date: 2014-08-02 00:06:24
Summary: Merge default
Affected #: 20 files
diff -r fd0377e5a7ecbc1a0b09f7f2389f9f0be2254d90 -r 8007f98027d69dbe530865afa912e5fb2d6fd997 CHANGELOG
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -17,6 +17,9 @@
- fix issue544 by only removing "@NUM" at the end of "::" separated parts
and if the part has an ".py" extension
+- don't use py.std import helper, rather import things directly.
+ Thanks Bruno Oliveira.
+
2.6
-----------------------------------
diff -r fd0377e5a7ecbc1a0b09f7f2389f9f0be2254d90 -r 8007f98027d69dbe530865afa912e5fb2d6fd997 _pytest/__init__.py
--- a/_pytest/__init__.py
+++ b/_pytest/__init__.py
@@ -1,2 +1,2 @@
#
-__version__ = '2.6.1.dev1'
+__version__ = '2.6.1.dev2'
diff -r fd0377e5a7ecbc1a0b09f7f2389f9f0be2254d90 -r 8007f98027d69dbe530865afa912e5fb2d6fd997 _pytest/assertion/oldinterpret.py
--- a/_pytest/assertion/oldinterpret.py
+++ b/_pytest/assertion/oldinterpret.py
@@ -1,3 +1,5 @@
+import traceback
+import types
import py
import sys, inspect
from compiler import parse, ast, pycodegen
@@ -477,7 +479,7 @@
def interpret(source, frame, should_fail=False):
module = Interpretable(parse(source, 'exec').node)
#print "got module", module
- if isinstance(frame, py.std.types.FrameType):
+ if isinstance(frame, types.FrameType):
frame = py.code.Frame(frame)
try:
module.run(frame)
@@ -487,7 +489,6 @@
except passthroughex:
raise
except:
- import traceback
traceback.print_exc()
if should_fail:
return ("(assertion failed, but when it was re-run for "
diff -r fd0377e5a7ecbc1a0b09f7f2389f9f0be2254d90 -r 8007f98027d69dbe530865afa912e5fb2d6fd997 _pytest/assertion/util.py
--- a/_pytest/assertion/util.py
+++ b/_pytest/assertion/util.py
@@ -1,4 +1,5 @@
"""Utilities for assertion debugging"""
+import pprint
import py
try:
@@ -168,6 +169,7 @@
If the input are bytes they will be safely converted to text.
"""
+ from difflib import ndiff
explanation = []
if isinstance(left, py.builtin.bytes):
left = u(repr(left)[1:-1]).replace(r'\n', '\n')
@@ -195,8 +197,8 @@
left = left[:-i]
right = right[:-i]
explanation += [line.strip('\n')
- for line in py.std.difflib.ndiff(left.splitlines(),
- right.splitlines())]
+ for line in ndiff(left.splitlines(),
+ right.splitlines())]
return explanation
@@ -214,8 +216,8 @@
explanation += [
u('Right contains more items, first extra item: %s') %
py.io.saferepr(right[len(left)],)]
- return explanation # + _diff_text(py.std.pprint.pformat(left),
- # py.std.pprint.pformat(right))
+ return explanation # + _diff_text(pprint.pformat(left),
+ # pprint.pformat(right))
def _compare_eq_set(left, right, verbose=False):
@@ -242,7 +244,7 @@
len(same)]
elif same:
explanation += [u('Common items:')]
- explanation += py.std.pprint.pformat(same).splitlines()
+ explanation += pprint.pformat(same).splitlines()
diff = set(k for k in common if left[k] != right[k])
if diff:
explanation += [u('Differing items:')]
@@ -252,12 +254,12 @@
extra_left = set(left) - set(right)
if extra_left:
explanation.append(u('Left contains more items:'))
- explanation.extend(py.std.pprint.pformat(
+ explanation.extend(pprint.pformat(
dict((k, left[k]) for k in extra_left)).splitlines())
extra_right = set(right) - set(left)
if extra_right:
explanation.append(u('Right contains more items:'))
- explanation.extend(py.std.pprint.pformat(
+ explanation.extend(pprint.pformat(
dict((k, right[k]) for k in extra_right)).splitlines())
return explanation
diff -r fd0377e5a7ecbc1a0b09f7f2389f9f0be2254d90 -r 8007f98027d69dbe530865afa912e5fb2d6fd997 _pytest/config.py
--- a/_pytest/config.py
+++ b/_pytest/config.py
@@ -1,4 +1,9 @@
""" command line options, ini-file and conftest.py processing. """
+import argparse
+import shlex
+import traceback
+import types
+import warnings
import py
# DON't import pytest here because it causes import cycle troubles
@@ -28,7 +33,7 @@
except ConftestImportFailure:
e = sys.exc_info()[1]
tw = py.io.TerminalWriter(sys.stderr)
- for line in py.std.traceback.format_exception(*e.excinfo):
+ for line in traceback.format_exception(*e.excinfo):
tw.line(line.rstrip(), red=True)
tw.line("ERROR: could not load %s\n" % (e.path), red=True)
return 4
@@ -70,7 +75,7 @@
elif not isinstance(args, (tuple, list)):
if not isinstance(args, str):
raise ValueError("not a string or argument list: %r" % (args,))
- args = py.std.shlex.split(args)
+ args = shlex.split(args)
pluginmanager = get_plugin_manager()
try:
if plugins:
@@ -227,7 +232,7 @@
class Argument:
- """class that mimics the necessary behaviour of py.std.optparse.Option """
+ """class that mimics the necessary behaviour of optparse.Option """
_typ_map = {
'int': int,
'string': str,
@@ -245,7 +250,7 @@
try:
help = attrs['help']
if '%default' in help:
- py.std.warnings.warn(
+ warnings.warn(
'pytest now uses argparse. "%default" should be'
' changed to "%(default)s" ',
FutureWarning,
@@ -261,7 +266,7 @@
if isinstance(typ, py.builtin._basestring):
if typ == 'choice':
if self.TYPE_WARN:
- py.std.warnings.warn(
+ warnings.warn(
'type argument to addoption() is a string %r.'
' For parsearg this is optional and when supplied '
' should be a type.'
@@ -273,7 +278,7 @@
attrs['type'] = type(attrs['choices'][0])
else:
if self.TYPE_WARN:
- py.std.warnings.warn(
+ warnings.warn(
'type argument to addoption() is a string %r.'
' For parsearg this should be a type.'
' (options: %s)' % (typ, names),
@@ -393,10 +398,10 @@
self.options.append(option)
-class MyOptionParser(py.std.argparse.ArgumentParser):
+class MyOptionParser(argparse.ArgumentParser):
def __init__(self, parser):
self._parser = parser
- py.std.argparse.ArgumentParser.__init__(self, usage=parser._usage,
+ argparse.ArgumentParser.__init__(self, usage=parser._usage,
add_help=False, formatter_class=DropShorterLongHelpFormatter)
def parse_args(self, args=None, namespace=None):
@@ -405,12 +410,12 @@
if argv:
for arg in argv:
if arg and arg[0] == '-':
- msg = py.std.argparse._('unrecognized arguments: %s')
+ msg = argparse._('unrecognized arguments: %s')
self.error(msg % ' '.join(argv))
getattr(args, FILE_OR_DIR).extend(argv)
return args
-class DropShorterLongHelpFormatter(py.std.argparse.HelpFormatter):
+class DropShorterLongHelpFormatter(argparse.HelpFormatter):
"""shorten help for long options that differ only in extra hyphens
- collapse **long** options that are the same except for extra hyphens
@@ -420,7 +425,7 @@
- cache result on action object as this is called at least 2 times
"""
def _format_action_invocation(self, action):
- orgstr = py.std.argparse.HelpFormatter._format_action_invocation(self, action)
+ orgstr = argparse.HelpFormatter._format_action_invocation(self, action)
if orgstr and orgstr[0] != '-': # only optional arguments
return orgstr
res = getattr(action, '_formatted_action_invocation', None)
@@ -744,7 +749,7 @@
self.hook.pytest_cmdline_preparse(config=self, args=args)
args = self._parser.parse_setoption(args, self.option)
if not args:
- args.append(py.std.os.getcwd())
+ args.append(os.getcwd())
self.args = args
def addinivalue_line(self, name, line):
@@ -782,11 +787,11 @@
if type == "pathlist":
dp = py.path.local(self.inicfg.config.path).dirpath()
l = []
- for relpath in py.std.shlex.split(value):
+ for relpath in shlex.split(value):
l.append(dp.join(relpath, abs=True))
return l
elif type == "args":
- return py.std.shlex.split(value)
+ return shlex.split(value)
elif type == "linelist":
return [t for t in map(lambda x: x.strip(), value.split("\n")) if t]
else:
@@ -867,7 +872,7 @@
mod = getattr(obj, name, None)
if mod is None:
modname = "pytest.%s" % name
- mod = py.std.types.ModuleType(modname)
+ mod = types.ModuleType(modname)
sys.modules[modname] = mod
mod.__all__ = []
setattr(obj, name, mod)
diff -r fd0377e5a7ecbc1a0b09f7f2389f9f0be2254d90 -r 8007f98027d69dbe530865afa912e5fb2d6fd997 _pytest/core.py
--- a/_pytest/core.py
+++ b/_pytest/core.py
@@ -1,6 +1,7 @@
"""
pytest PluginManager, basic initialization and tracing.
"""
+import os
import sys
import inspect
import py
@@ -154,7 +155,7 @@
# API for bootstrapping
#
def _envlist(self, varname):
- val = py.std.os.environ.get(varname, None)
+ val = os.environ.get(varname, None)
if val is not None:
return val.split(',')
return ()
@@ -221,7 +222,7 @@
return self.import_plugin(modname[7:])
raise
except:
- e = py.std.sys.exc_info()[1]
+ e = sys.exc_info()[1]
import pytest
if not hasattr(pytest, 'skip') or not isinstance(e, pytest.skip.Exception):
raise
diff -r fd0377e5a7ecbc1a0b09f7f2389f9f0be2254d90 -r 8007f98027d69dbe530865afa912e5fb2d6fd997 _pytest/doctest.py
--- a/_pytest/doctest.py
+++ b/_pytest/doctest.py
@@ -1,5 +1,6 @@
""" discover and run doctests in modules and test files."""
-
+from __future__ import absolute_import
+import traceback
import pytest, py
from _pytest.python import FixtureRequest, FuncFixtureInfo
from py._code.code import TerminalRepr, ReprFileLocation
@@ -43,7 +44,7 @@
self.runner.run(self.dtest)
def repr_failure(self, excinfo):
- doctest = py.std.doctest
+ import doctest
if excinfo.errisinstance((doctest.DocTestFailure,
doctest.UnexpectedException)):
doctestfailure = excinfo.value
@@ -56,8 +57,8 @@
lineno = test.lineno + example.lineno + 1
message = excinfo.type.__name__
reprlocation = ReprFileLocation(filename, lineno, message)
- checker = py.std.doctest.OutputChecker()
- REPORT_UDIFF = py.std.doctest.REPORT_UDIFF
+ checker = doctest.OutputChecker()
+ REPORT_UDIFF = doctest.REPORT_UDIFF
filelines = py.path.local(filename).readlines(cr=0)
lines = []
if lineno is not None:
@@ -78,7 +79,7 @@
inner_excinfo = py.code.ExceptionInfo(excinfo.value.exc_info)
lines += ["UNEXPECTED EXCEPTION: %s" %
repr(inner_excinfo.value)]
- lines += py.std.traceback.format_exception(*excinfo.value.exc_info)
+ lines += traceback.format_exception(*excinfo.value.exc_info)
return ReprFailDoctest(reprlocation, lines)
else:
return super(DoctestItem, self).repr_failure(excinfo)
@@ -88,7 +89,7 @@
class DoctestTextfile(DoctestItem, pytest.File):
def runtest(self):
- doctest = py.std.doctest
+ import doctest
# satisfy `FixtureRequest` constructor...
self.funcargs = {}
fm = self.session._fixturemanager
@@ -106,7 +107,7 @@
class DoctestModule(pytest.File):
def collect(self):
- doctest = py.std.doctest
+ import doctest
if self.fspath.basename == "conftest.py":
module = self.config._conftest.importconftest(self.fspath)
else:
diff -r fd0377e5a7ecbc1a0b09f7f2389f9f0be2254d90 -r 8007f98027d69dbe530865afa912e5fb2d6fd997 _pytest/genscript.py
--- a/_pytest/genscript.py
+++ b/_pytest/genscript.py
@@ -2,8 +2,9 @@
import py
import sys
+
def find_toplevel(name):
- for syspath in py.std.sys.path:
+ for syspath in sys.path:
base = py.path.local(syspath)
lib = base/name
if lib.check(dir=1):
@@ -29,9 +30,10 @@
return name2src
def compress_mapping(mapping):
- data = py.std.pickle.dumps(mapping, 2)
- data = py.std.zlib.compress(data, 9)
- data = py.std.base64.encodestring(data)
+ import base64, pickle, zlib
+ data = pickle.dumps(mapping, 2)
+ data = zlib.compress(data, 9)
+ data = base64.encodestring(data)
data = data.decode('ascii')
return data
diff -r fd0377e5a7ecbc1a0b09f7f2389f9f0be2254d90 -r 8007f98027d69dbe530865afa912e5fb2d6fd997 _pytest/junitxml.py
--- a/_pytest/junitxml.py
+++ b/_pytest/junitxml.py
@@ -2,7 +2,6 @@
Based on initial code from Ross Lawley.
"""
-
import py
import os
import re
@@ -10,20 +9,13 @@
import time
# Python 2.X and 3.X compatibility
-try:
- unichr(65)
-except NameError:
+if sys.version_info[0] < 3:
+ from codecs import open
+else:
unichr = chr
-try:
- unicode('A')
-except NameError:
unicode = str
-try:
- long(1)
-except NameError:
long = int
-
class Junit(py.xml.Namespace):
pass
@@ -206,11 +198,7 @@
self.suite_start_time = time.time()
def pytest_sessionfinish(self):
- if py.std.sys.version_info[0] < 3:
- logfile = py.std.codecs.open(self.logfile, 'w', encoding='utf-8')
- else:
- logfile = open(self.logfile, 'w', encoding='utf-8')
-
+ logfile = open(self.logfile, 'w', encoding='utf-8')
suite_stop_time = time.time()
suite_time_delta = suite_stop_time - self.suite_start_time
numtests = self.passed + self.failed
diff -r fd0377e5a7ecbc1a0b09f7f2389f9f0be2254d90 -r 8007f98027d69dbe530865afa912e5fb2d6fd997 _pytest/main.py
--- a/_pytest/main.py
+++ b/_pytest/main.py
@@ -1,4 +1,5 @@
""" core implementation of testing process: init, session, runtest loop. """
+import re
import py
import pytest, _pytest
@@ -19,7 +20,7 @@
EXIT_INTERNALERROR = 3
EXIT_USAGEERROR = 4
-name_re = py.std.re.compile("^[a-zA-Z_]\w*$")
+name_re = re.compile("^[a-zA-Z_]\w*$")
def pytest_addoption(parser):
parser.addini("norecursedirs", "directory patterns to avoid for recursion",
@@ -315,7 +316,7 @@
except py.builtin._sysex:
raise
except:
- failure = py.std.sys.exc_info()
+ failure = sys.exc_info()
setattr(self, exattrname, failure)
raise
setattr(self, attrname, res)
diff -r fd0377e5a7ecbc1a0b09f7f2389f9f0be2254d90 -r 8007f98027d69dbe530865afa912e5fb2d6fd997 _pytest/pdb.py
--- a/_pytest/pdb.py
+++ b/_pytest/pdb.py
@@ -1,7 +1,11 @@
""" interactive debugging with PDB, the Python Debugger. """
+from __future__ import absolute_import
+import pdb
+import sys
-import pytest, py
-import sys
+import pytest
+import py
+
def pytest_addoption(parser):
group = parser.getgroup("general")
@@ -16,10 +20,10 @@
if config.getvalue("usepdb"):
config.pluginmanager.register(PdbInvoke(), 'pdbinvoke')
- old = (py.std.pdb.set_trace, pytestPDB._pluginmanager)
+ old = (pdb.set_trace, pytestPDB._pluginmanager)
def fin():
- py.std.pdb.set_trace, pytestPDB._pluginmanager = old
- py.std.pdb.set_trace = pytest.set_trace
+ pdb.set_trace, pytestPDB._pluginmanager = old
+ pdb.set_trace = pytest.set_trace
pytestPDB._pluginmanager = config.pluginmanager
config._cleanup.append(fin)
@@ -38,7 +42,7 @@
tw = py.io.TerminalWriter()
tw.line()
tw.sep(">", "PDB set_trace (IO-capturing turned off)")
- py.std.pdb.Pdb().set_trace(frame)
+ pdb.Pdb().set_trace(frame)
class PdbInvoke:
@@ -74,7 +78,8 @@
def _postmortem_traceback(excinfo):
# A doctest.UnexpectedException is not useful for post_mortem.
# Use the underlying exception instead:
- if isinstance(excinfo.value, py.std.doctest.UnexpectedException):
+ from doctest import UnexpectedException
+ if isinstance(excinfo.value, UnexpectedException):
return excinfo.value.exc_info[2]
else:
return excinfo._excinfo[2]
@@ -88,7 +93,6 @@
def post_mortem(t):
- pdb = py.std.pdb
class Pdb(pdb.Pdb):
def get_stack(self, f, t):
stack, i = pdb.Pdb.get_stack(self, f, t)
diff -r fd0377e5a7ecbc1a0b09f7f2389f9f0be2254d90 -r 8007f98027d69dbe530865afa912e5fb2d6fd997 _pytest/pytester.py
--- a/_pytest/pytester.py
+++ b/_pytest/pytester.py
@@ -1,15 +1,21 @@
""" (disabled by default) support for testing pytest and pytest plugins. """
-
-import py, pytest
-import sys, os
+import inspect
+import sys
+import os
import codecs
import re
import time
+import platform
from fnmatch import fnmatch
-from _pytest.main import Session, EXIT_OK
+import subprocess
+
+import py
+import pytest
from py.builtin import print_
from _pytest.core import HookRelay
+from _pytest.main import Session, EXIT_OK
+
def get_public_names(l):
"""Only return names from iterator l without a leading underscore."""
@@ -87,10 +93,10 @@
def _makecallparser(self, method):
name = method.__name__
- args, varargs, varkw, default = py.std.inspect.getargspec(method)
+ args, varargs, varkw, default = inspect.getargspec(method)
if not args or args[0] != "self":
args.insert(0, 'self')
- fspec = py.std.inspect.formatargspec(args, varargs, varkw, default)
+ fspec = inspect.formatargspec(args, varargs, varkw, default)
# we use exec because we want to have early type
# errors on wrong input arguments, using
# *args/**kwargs delays this and gives errors
@@ -122,7 +128,7 @@
__tracebackhide__ = True
i = 0
entries = list(entries)
- backlocals = py.std.sys._getframe(1).f_locals
+ backlocals = sys._getframe(1).f_locals
while entries:
name, check = entries.pop(0)
for ind, call in enumerate(self.calls[i:]):
@@ -210,7 +216,7 @@
def finalize(self):
for p in self._syspathremove:
- py.std.sys.path.remove(p)
+ sys.path.remove(p)
if hasattr(self, '_olddir'):
self._olddir.chdir()
# delete modules that have been loaded from tmpdir
@@ -283,7 +289,7 @@
def syspathinsert(self, path=None):
if path is None:
path = self.tmpdir
- py.std.sys.path.insert(0, str(path))
+ sys.path.insert(0, str(path))
self._syspathremove.append(str(path))
def mkdir(self, name):
@@ -426,9 +432,8 @@
env['PYTHONPATH'] = os.pathsep.join(filter(None, [
str(os.getcwd()), env.get('PYTHONPATH', '')]))
kw['env'] = env
- #print "env", env
- return py.std.subprocess.Popen(cmdargs,
- stdout=stdout, stderr=stderr, **kw)
+ return subprocess.Popen(cmdargs,
+ stdout=stdout, stderr=stderr, **kw)
def run(self, *cmdargs):
return self._run(*cmdargs)
@@ -474,9 +479,9 @@
def _getpybinargs(self, scriptname):
if not self.request.config.getvalue("notoolsonpath"):
# XXX we rely on script referring to the correct environment
- # we cannot use "(py.std.sys.executable,script)"
+ # we cannot use "(sys.executable,script)"
# because on windows the script is e.g. a py.test.exe
- return (py.std.sys.executable, _pytest_fullpath,) # noqa
+ return (sys.executable, _pytest_fullpath,) # noqa
else:
pytest.skip("cannot run %r with --no-tools-on-path" % scriptname)
@@ -496,7 +501,7 @@
def runpython_c(self, command):
command = self._getsysprepend() + command
- return self.run(py.std.sys.executable, "-c", command)
+ return self.run(sys.executable, "-c", command)
def runpytest(self, *args):
p = py.path.local.make_numbered_dir(prefix="runpytest-",
@@ -523,7 +528,7 @@
def spawn(self, cmd, expect_timeout=10.0):
pexpect = pytest.importorskip("pexpect", "3.0")
- if hasattr(sys, 'pypy_version_info') and '64' in py.std.platform.machine():
+ if hasattr(sys, 'pypy_version_info') and '64' in platform.machine():
pytest.skip("pypy-64 bit not supported")
if sys.platform == "darwin":
pytest.xfail("pexpect does not work reliably on darwin?!")
@@ -670,7 +675,7 @@
def fnmatch_lines(self, lines2):
def show(arg1, arg2):
- py.builtin.print_(arg1, arg2, file=py.std.sys.stderr)
+ py.builtin.print_(arg1, arg2, file=sys.stderr)
lines2 = self._getlines(lines2)
lines1 = self.lines[:]
nextline = None
diff -r fd0377e5a7ecbc1a0b09f7f2389f9f0be2254d90 -r 8007f98027d69dbe530865afa912e5fb2d6fd997 _pytest/recwarn.py
--- a/_pytest/recwarn.py
+++ b/_pytest/recwarn.py
@@ -1,7 +1,8 @@
""" recording warnings during test function execution. """
-import py
import sys
+import warnings
+
def pytest_funcarg__recwarn(request):
"""Return a WarningsRecorder instance that provides these methods:
@@ -13,7 +14,6 @@
on warning categories.
"""
if sys.version_info >= (2,7):
- import warnings
oldfilters = warnings.filters[:]
warnings.simplefilter('default')
def reset_filters():
@@ -30,26 +30,24 @@
""" assert that calling ``func(*args, **kwargs)``
triggers a DeprecationWarning.
"""
- warningmodule = py.std.warnings
l = []
- oldwarn_explicit = getattr(warningmodule, 'warn_explicit')
+ oldwarn_explicit = getattr(warnings, 'warn_explicit')
def warn_explicit(*args, **kwargs):
l.append(args)
oldwarn_explicit(*args, **kwargs)
- oldwarn = getattr(warningmodule, 'warn')
+ oldwarn = getattr(warnings, 'warn')
def warn(*args, **kwargs):
l.append(args)
oldwarn(*args, **kwargs)
- warningmodule.warn_explicit = warn_explicit
- warningmodule.warn = warn
+ warnings.warn_explicit = warn_explicit
+ warnings.warn = warn
try:
ret = func(*args, **kwargs)
finally:
- warningmodule.warn_explicit = warn_explicit
- warningmodule.warn = warn
+ warnings.warn_explicit = warn_explicit
+ warnings.warn = warn
if not l:
- #print warningmodule
__tracebackhide__ = True
raise AssertionError("%r did not produce DeprecationWarning" %(func,))
return ret
@@ -65,7 +63,6 @@
class WarningsRecorder:
def __init__(self):
- warningmodule = py.std.warnings
self.list = []
def showwarning(message, category, filename, lineno, line=0):
self.list.append(RecordedWarning(
@@ -76,8 +73,8 @@
except TypeError:
# < python2.6
self.old_showwarning(message, category, filename, lineno)
- self.old_showwarning = warningmodule.showwarning
- warningmodule.showwarning = showwarning
+ self.old_showwarning = warnings.showwarning
+ warnings.showwarning = showwarning
def pop(self, cls=Warning):
""" pop the first recorded warning, raise exception if not exists."""
@@ -88,7 +85,6 @@
assert 0, "%r not found in %r" %(cls, self.list)
#def resetregistry(self):
- # import warnings
# warnings.onceregistry.clear()
# warnings.__warningregistry__.clear()
@@ -96,4 +92,4 @@
self.list[:] = []
def finalize(self):
- py.std.warnings.showwarning = self.old_showwarning
+ warnings.showwarning = self.old_showwarning
diff -r fd0377e5a7ecbc1a0b09f7f2389f9f0be2254d90 -r 8007f98027d69dbe530865afa912e5fb2d6fd997 _pytest/runner.py
--- a/_pytest/runner.py
+++ b/_pytest/runner.py
@@ -1,9 +1,10 @@
""" basic collect and runtest protocol implementations """
+import bdb
+import sys
+from time import time
import py
import pytest
-import sys
-from time import time
from py._code.code import TerminalRepr
def pytest_namespace():
@@ -118,7 +119,7 @@
return call.excinfo and not (
hasattr(report, "wasxfail") or
call.excinfo.errisinstance(skip.Exception) or
- call.excinfo.errisinstance(py.std.bdb.BdbQuit))
+ call.excinfo.errisinstance(bdb.BdbQuit))
def call_runtest_hook(item, when, **kwds):
hookname = "pytest_runtest_" + when
diff -r fd0377e5a7ecbc1a0b09f7f2389f9f0be2254d90 -r 8007f98027d69dbe530865afa912e5fb2d6fd997 _pytest/skipping.py
--- a/_pytest/skipping.py
+++ b/_pytest/skipping.py
@@ -1,7 +1,10 @@
""" support for skip/xfail functions and markers. """
+import os
+import sys
+import traceback
-import py, pytest
-import sys
+import py
+import pytest
def pytest_addoption(parser):
group = parser.getgroup("general")
@@ -79,7 +82,7 @@
msg = [" " * (self.exc[1].offset + 4) + "^",]
msg.append("SyntaxError: invalid syntax")
else:
- msg = py.std.traceback.format_exception_only(*self.exc[:2])
+ msg = traceback.format_exception_only(*self.exc[:2])
pytest.fail("Error evaluating %r expression\n"
" %s\n"
"%s"
@@ -87,7 +90,7 @@
pytrace=False)
def _getglobals(self):
- d = {'os': py.std.os, 'sys': py.std.sys, 'config': self.item.config}
+ d = {'os': os, 'sys': sys, 'config': self.item.config}
func = self.item.obj
try:
d.update(func.__globals__)
diff -r fd0377e5a7ecbc1a0b09f7f2389f9f0be2254d90 -r 8007f98027d69dbe530865afa912e5fb2d6fd997 _pytest/terminal.py
--- a/_pytest/terminal.py
+++ b/_pytest/terminal.py
@@ -5,6 +5,8 @@
import pytest
import py
import sys
+import time
+
def pytest_addoption(parser):
group = parser.getgroup("terminal reporting", "reporting", after="general")
@@ -49,7 +51,7 @@
optvalue = config.option.report
if optvalue:
py.builtin.print_("DEPRECATED: use -r instead of --report option.",
- file=py.std.sys.stderr)
+ file=sys.stderr)
if optvalue:
for setting in optvalue.split(","):
setting = setting.strip()
@@ -95,7 +97,7 @@
self.stats = {}
self.startdir = self.curdir = py.path.local()
if file is None:
- file = py.std.sys.stdout
+ file = sys.stdout
self._tw = self.writer = py.io.TerminalWriter(file)
if self.config.option.color == 'yes':
self._tw.hasmarkup = True
@@ -265,7 +267,7 @@
@pytest.mark.trylast
def pytest_sessionstart(self, session):
- self._sessionstarttime = py.std.time.time()
+ self._sessionstarttime = time.time()
if not self.showheader:
return
self.write_sep("=", "test session starts", bold=True)
@@ -466,7 +468,7 @@
self._tw.line(content)
def summary_stats(self):
- session_duration = py.std.time.time() - self._sessionstarttime
+ session_duration = time.time() - self._sessionstarttime
keys = ("failed passed skipped deselected "
"xfailed xpassed warnings").split()
diff -r fd0377e5a7ecbc1a0b09f7f2389f9f0be2254d90 -r 8007f98027d69dbe530865afa912e5fb2d6fd997 _pytest/tmpdir.py
--- a/_pytest/tmpdir.py
+++ b/_pytest/tmpdir.py
@@ -1,7 +1,11 @@
""" support for providing temporary directories to test functions. """
-import pytest, py
+import re
+
+import pytest
+import py
from _pytest.monkeypatch import monkeypatch
+
class TempdirHandler:
def __init__(self, config):
self.config = config
@@ -63,7 +67,7 @@
path object.
"""
name = request.node.name
- name = py.std.re.sub("[\W]", "_", name)
+ name = re.sub("[\W]", "_", name)
MAXVAL = 30
if len(name) > MAXVAL:
name = name[:MAXVAL]
diff -r fd0377e5a7ecbc1a0b09f7f2389f9f0be2254d90 -r 8007f98027d69dbe530865afa912e5fb2d6fd997 _pytest/unittest.py
--- a/_pytest/unittest.py
+++ b/_pytest/unittest.py
@@ -1,27 +1,25 @@
""" discovery and running of std-library "unittest" style tests. """
-import pytest, py
+from __future__ import absolute_import
+import traceback
import sys
+import pytest
+import py
+
+
# for transfering markers
from _pytest.python import transfer_markers
-def is_unittest(obj):
- """Is obj a subclass of unittest.TestCase?"""
- unittest = sys.modules.get('unittest')
- if unittest is None:
- return # nobody can have derived unittest.TestCase
+def pytest_pycollect_makeitem(collector, name, obj):
+ # has unittest been imported and is obj a subclass of its TestCase?
try:
- return issubclass(obj, unittest.TestCase)
- except KeyboardInterrupt:
- raise
- except:
- return False
-
-
-def pytest_pycollect_makeitem(collector, name, obj):
- if is_unittest(obj):
- return UnitTestCase(name, parent=collector)
+ if not issubclass(obj, sys.modules["unittest"].TestCase):
+ return
+ except Exception:
+ return
+ # yes, so let's collect it
+ return UnitTestCase(name, parent=collector)
class UnitTestCase(pytest.Class):
@@ -41,11 +39,12 @@
super(UnitTestCase, self).setup()
def collect(self):
+ from unittest import TestLoader
cls = self.obj
if not getattr(cls, "__test__", True):
return
self.session._fixturemanager.parsefactories(self, unittest=True)
- loader = py.std.unittest.TestLoader()
+ loader = TestLoader()
module = self.getparent(pytest.Module).obj
foundsomething = False
for name in loader.getTestCaseNames(self.obj):
@@ -90,7 +89,7 @@
except TypeError:
try:
try:
- l = py.std.traceback.format_exception(*rawexcinfo)
+ l = traceback.format_exception(*rawexcinfo)
l.insert(0, "NOTE: Incompatible Exception Representation, "
"displaying natively:\n\n")
pytest.fail("".join(l), pytrace=False)
diff -r fd0377e5a7ecbc1a0b09f7f2389f9f0be2254d90 -r 8007f98027d69dbe530865afa912e5fb2d6fd997 setup.py
--- a/setup.py
+++ b/setup.py
@@ -27,7 +27,7 @@
name='pytest',
description='pytest: simple powerful testing with Python',
long_description=long_description,
- version='2.6.1.dev1',
+ version='2.6.1.dev2',
url='http://pytest.org',
license='MIT license',
platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],
https://bitbucket.org/hpk42/pytest/commits/eb6f0a6eb8a9/
Changeset: eb6f0a6eb8a9
User: flub
Date: 2014-08-02 00:11:25
Summary: Mention change in -v output in changelog
Affected #: 1 file
diff -r 8007f98027d69dbe530865afa912e5fb2d6fd997 -r eb6f0a6eb8a98771c8b81d2028fc39cec783c52d CHANGELOG
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,9 @@
NEXT
-----------------------------------
+- No longer show line numbers in the --verbose output, the output is now
+ purely the nodeid. The line number is still shown in failure reports.
+
- fix issue547 capsys/capfd also work when output capturing ("-s") is disabled.
- address issue170: allow pytest.mark.xfail(...) to specify expected exceptions via
Repository URL: https://bitbucket.org/hpk42/pytest/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the pytest-commit
mailing list