flat is better than nested (cont'd):
- pytest.py is new module, making "python -m pytest" work always - _pytest/*.py now contains core.py, hookspec and the plugins, no sub packages
This commit is contained in:
parent
2e4e9eb745
commit
929291775e
|
@ -3,7 +3,7 @@ support for presented detailed information in failing assertions.
|
|||
"""
|
||||
import py
|
||||
import sys
|
||||
from pytest.plugin.monkeypatch import monkeypatch
|
||||
from _pytest.monkeypatch import monkeypatch
|
||||
|
||||
def pytest_addoption(parser):
|
||||
group = parser.getgroup("debugconfig")
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import py
|
||||
import sys, os
|
||||
from pytest.main import PluginManager
|
||||
from _pytest.core import PluginManager
|
||||
import pytest
|
||||
|
||||
def pytest_cmdline_parse(pluginmanager, args):
|
|
@ -6,8 +6,7 @@ All else is in pytest/plugin.
|
|||
import sys, os
|
||||
import inspect
|
||||
import py
|
||||
import pytest
|
||||
from pytest import hookspec # the extension point definitions
|
||||
from _pytest import hookspec # the extension point definitions
|
||||
|
||||
assert py.__version__.split(".")[:2] >= ['2', '0'], ("installation problem: "
|
||||
"%s is too old, remove or upgrade 'py'" % (py.__version__))
|
||||
|
@ -206,6 +205,7 @@ class PluginManager(object):
|
|||
self.consider_module(mod)
|
||||
|
||||
def pytest_plugin_registered(self, plugin):
|
||||
import pytest
|
||||
dic = self.call_plugin(plugin, "pytest_namespace", {}) or {}
|
||||
if dic:
|
||||
self._setns(pytest, dic)
|
||||
|
@ -216,6 +216,7 @@ class PluginManager(object):
|
|||
{'config': self._config})
|
||||
|
||||
def _setns(self, obj, dic):
|
||||
import pytest
|
||||
for name, value in dic.items():
|
||||
if isinstance(value, dict):
|
||||
mod = getattr(obj, name, None)
|
||||
|
@ -225,14 +226,13 @@ class PluginManager(object):
|
|||
sys.modules[modname] = mod
|
||||
mod.__all__ = []
|
||||
setattr(obj, name, mod)
|
||||
#print "setns", mod, value
|
||||
obj.__all__.append(name)
|
||||
self._setns(mod, value)
|
||||
else:
|
||||
#print "setting", name, value, "on", obj
|
||||
setattr(obj, name, value)
|
||||
obj.__all__.append(name)
|
||||
#print "appending", name, "to", obj
|
||||
#pytest.__all__.append(name) # don't show in help(py.test)
|
||||
#if obj != pytest:
|
||||
# pytest.__all__.append(name)
|
||||
setattr(pytest, name, value)
|
||||
|
||||
def pytest_terminal_summary(self, terminalreporter):
|
||||
|
@ -300,7 +300,7 @@ def importplugin(importspec):
|
|||
try:
|
||||
if name.startswith("pytest_"):
|
||||
name = importspec[7:]
|
||||
return __import__("pytest.plugin.%s" %(name), None, None, '__doc__')
|
||||
return __import__("_pytest.%s" %(name), None, None, '__doc__')
|
||||
except ImportError:
|
||||
e = py.std.sys.exc_info()[1]
|
||||
if str(e).find(name) == -1:
|
||||
|
@ -411,7 +411,10 @@ class HookCaller:
|
|||
self.trace.root.indent -= 1
|
||||
return res
|
||||
|
||||
_preinit = [PluginManager(load=True)] # triggers default plugin importing
|
||||
_preinit = []
|
||||
|
||||
def _preloadplugins():
|
||||
_preinit.append(PluginManager(load=True))
|
||||
|
||||
def main(args=None, plugins=None):
|
||||
""" returned exit code integer, after an in-process testing run
|
||||
|
@ -446,5 +449,3 @@ def main(args=None, plugins=None):
|
|||
class UsageError(Exception):
|
||||
""" error in py.test usage or invocation"""
|
||||
|
||||
if __name__ == '__main__':
|
||||
raise SystemExit(main())
|
|
@ -10,6 +10,9 @@ def find_toplevel(name):
|
|||
lib = base/name
|
||||
if lib.check(dir=1):
|
||||
return lib
|
||||
mod = base.join("%s.py" % name)
|
||||
if mod.check(file=1):
|
||||
return mod
|
||||
raise LookupError(name)
|
||||
|
||||
def pkgname(toplevel, rootpath, path):
|
||||
|
@ -19,12 +22,14 @@ def pkgname(toplevel, rootpath, path):
|
|||
def pkg_to_mapping(name):
|
||||
toplevel = find_toplevel(name)
|
||||
name2src = {}
|
||||
for pyfile in toplevel.visit('*.py'):
|
||||
pkg = pkgname(name, toplevel, pyfile)
|
||||
name2src[pkg] = pyfile.read()
|
||||
if toplevel.check(file=1): # module
|
||||
name2src[toplevel.purebasename] = toplevel.read()
|
||||
else: # package
|
||||
for pyfile in toplevel.visit('*.py'):
|
||||
pkg = pkgname(name, toplevel, pyfile)
|
||||
name2src[pkg] = pyfile.read()
|
||||
return name2src
|
||||
|
||||
|
||||
def compress_mapping(mapping):
|
||||
data = pickle.dumps(mapping, 2)
|
||||
data = zlib.compress(data, 9)
|
||||
|
@ -60,7 +65,7 @@ def pytest_cmdline_main(config):
|
|||
if genscript:
|
||||
script = generate_script(
|
||||
'import py; raise SystemExit(py.test.cmdline.main())',
|
||||
['py', 'pytest'],
|
||||
['py', '_pytest', 'pytest'],
|
||||
)
|
||||
|
||||
genscript = py.path.local(genscript)
|
|
@ -25,7 +25,7 @@ def pytest_addoption(parser):
|
|||
|
||||
def pytest_cmdline_main(config):
|
||||
if config.option.version:
|
||||
p = py.path.local(pytest.__file__).dirpath()
|
||||
p = py.path.local(pytest.__file__)
|
||||
sys.stderr.write("This is py.test version %s, imported from %s\n" %
|
||||
(pytest.__version__, p))
|
||||
return 0
|
|
@ -139,9 +139,9 @@ def pytest_runtest_teardown(item):
|
|||
""" called after ``pytest_runtest_call``. """
|
||||
|
||||
def pytest_runtest_makereport(item, call):
|
||||
""" return a :py:class:`pytest.plugin.runner.TestReport` object
|
||||
""" return a :py:class:`_pytest.runner.TestReport` object
|
||||
for the given :py:class:`pytest.Item` and
|
||||
:py:class:`pytest.plugin.runner.CallInfo`.
|
||||
:py:class:`_pytest.runner.CallInfo`.
|
||||
"""
|
||||
pytest_runtest_makereport.firstresult = True
|
||||
|
||||
|
@ -181,7 +181,7 @@ def pytest_assertrepr_compare(config, op, left, right):
|
|||
"""
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
# hooks for influencing reporting (invoked from pytest_terminal)
|
||||
# hooks for influencing reporting (invoked from _pytest_terminal)
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
def pytest_report_header(config):
|
|
@ -6,9 +6,9 @@ import re
|
|||
import inspect
|
||||
import time
|
||||
from fnmatch import fnmatch
|
||||
from pytest.plugin.session import Session
|
||||
from _pytest.session import Session
|
||||
from py.builtin import print_
|
||||
from pytest.main import HookRelay
|
||||
from _pytest.core import HookRelay
|
||||
|
||||
def pytest_addoption(parser):
|
||||
group = parser.getgroup("pylib")
|
||||
|
@ -492,7 +492,7 @@ class TmpTestdir:
|
|||
if self.request.config.getvalue("notoolsonpath"):
|
||||
py.test.skip("--no-tools-on-path prevents running pexpect-spawn tests")
|
||||
basetemp = self.tmpdir.mkdir("pexpect")
|
||||
invoke = self._getpybinargs("py.test")[0]
|
||||
invoke = " ".join(map(str, self._getpybinargs("py.test")))
|
||||
cmd = "%s --basetemp=%s %s" % (invoke, basetemp, string)
|
||||
return self.spawn(cmd, expect_timeout=expect_timeout)
|
||||
|
|
@ -5,8 +5,8 @@ import sys
|
|||
import pytest
|
||||
from py._code.code import TerminalRepr
|
||||
|
||||
cutdir = py.path.local(pytest.__file__).dirpath()
|
||||
|
||||
import _pytest
|
||||
cutdir = py.path.local(_pytest.__file__).dirpath()
|
||||
|
||||
def pytest_addoption(parser):
|
||||
group = parser.getgroup("general")
|
||||
|
@ -611,7 +611,7 @@ class FuncargRequest:
|
|||
This method is useful if you don't want to have a keyword/marker
|
||||
on all function invocations.
|
||||
|
||||
:arg marker: a :py:class:`pytest.plugin.mark.MarkDecorator` object
|
||||
:arg marker: a :py:class:`_pytest.mark.MarkDecorator` object
|
||||
created by a call to ``py.test.mark.NAME(...)``.
|
||||
"""
|
||||
if not isinstance(marker, py.test.mark.XYZ.__class__):
|
||||
|
@ -712,7 +712,7 @@ class FuncargRequest:
|
|||
raise self.LookupError(msg)
|
||||
|
||||
def showfuncargs(config):
|
||||
from pytest.plugin.session import Session
|
||||
from _pytest.session import Session
|
||||
session = Session(config)
|
||||
session.perform_collect()
|
||||
if session.items:
|
|
@ -1,9 +1,9 @@
|
|||
""" core implementation of testing process: init, session, runtest loop. """
|
||||
|
||||
import py
|
||||
import pytest
|
||||
import pytest, _pytest
|
||||
import os, sys
|
||||
tracebackcutdir = py.path.local(pytest.__file__).dirpath()
|
||||
tracebackcutdir = py.path.local(_pytest.__file__).dirpath()
|
||||
|
||||
# exitcodes for the command line
|
||||
EXIT_OK = 0
|
||||
|
@ -125,7 +125,8 @@ def compatproperty(name):
|
|||
py.log._apiwarn("2.0", "use pytest.%s for "
|
||||
"test collection and item classes" % name)
|
||||
return getattr(pytest, name)
|
||||
return property(fget)
|
||||
return property(fget, None, None,
|
||||
"deprecated attribute %r, use pytest.%s" % (name,name))
|
||||
|
||||
class Node(object):
|
||||
""" base class for all Nodes in the collection tree.
|
|
@ -26,14 +26,16 @@ New Features
|
|||
|
||||
- new invocations through Python interpreter and from Python::
|
||||
|
||||
python -m pytest # on all pythons >= 2.7
|
||||
python -m pytest.main # on all pythons >= 2.5
|
||||
python -m pytest # on all pythons >= 2.5
|
||||
|
||||
or from a python program::
|
||||
|
||||
import pytest ; pytest.main(args, plugins)
|
||||
|
||||
see http://pytest.org/2.0.0/usage.html for details.
|
||||
|
||||
- new and better reporting information in assert expressions
|
||||
which compare lists, sequences or strings.
|
||||
if comparing lists, sequences or strings.
|
||||
|
||||
see http://pytest.org/2.0.0/assert.html for details.
|
||||
|
||||
|
@ -42,7 +44,7 @@ New Features
|
|||
|
||||
[pytest]
|
||||
norecursedirs = .hg data* # don't ever recurse in such dirs
|
||||
addopts = -x --pyargs # add these options by default
|
||||
addopts = -x --pyargs # add these command line options by default
|
||||
|
||||
see http://pytest.org/2.0.0/customize.html
|
||||
|
||||
|
@ -51,9 +53,10 @@ New Features
|
|||
|
||||
py.test --pyargs unittest
|
||||
|
||||
- add a new "-q" option which decreases verbosity and prints a more
|
||||
- new "-q" option which decreases verbosity and prints a more
|
||||
nose/unittest-style "dot" output.
|
||||
|
||||
|
||||
Fixes
|
||||
-----------------------
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# content of conftest.py
|
||||
|
||||
import py
|
||||
import pytest
|
||||
|
||||
def pytest_collect_file(path, parent):
|
||||
if path.ext == ".yml" and path.basename.startswith("test"):
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
creating and managing test function arguments
|
||||
==============================================================
|
||||
|
||||
.. currentmodule:: pytest.plugin.python
|
||||
.. currentmodule:: _pytest.python
|
||||
|
||||
|
||||
.. _`funcargs`:
|
||||
|
@ -92,7 +92,7 @@ Each funcarg factory receives a **request** object which is tied to a
|
|||
specific test function call. A request object is passed to a funcarg
|
||||
factory and provides access to test configuration and context:
|
||||
|
||||
.. autoclass:: pytest.plugin.python.FuncargRequest()
|
||||
.. autoclass:: _pytest.python.FuncargRequest()
|
||||
:members: function,cls,module,keywords,config
|
||||
|
||||
.. _`useful caching and finalization helpers`:
|
||||
|
|
|
@ -5,8 +5,8 @@ py.test: no-boilerplate testing with Python
|
|||
|
||||
.. note::
|
||||
version 2.0 introduces ``pytest`` as the main Python import name
|
||||
but for historic reasons ``py.test`` remains fully valid and
|
||||
represents the same package.
|
||||
but for compatibility reasons you may continue to use ``py.test``
|
||||
in your test code.
|
||||
|
||||
Welcome to ``py.test`` documentation:
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
mark test functions with attributes
|
||||
=================================================================
|
||||
|
||||
.. currentmodule:: pytest.plugin.mark
|
||||
.. currentmodule:: _pytest.mark
|
||||
|
||||
By using the ``py.test.mark`` helper you can instantiate
|
||||
decorators that will set named meta data on test functions.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
monkeypatching/mocking modules and environments
|
||||
================================================================
|
||||
|
||||
.. currentmodule:: pytest.plugin.monkeypatch
|
||||
.. currentmodule:: _pytest.monkeypatch
|
||||
|
||||
Sometimes tests need to invoke functionality which depends
|
||||
on global settings or which invokes code which cannot be easily
|
||||
|
|
|
@ -4,7 +4,7 @@ Running test written for nose
|
|||
.. include:: links.inc
|
||||
|
||||
py.test has basic support for running tests written for nose_.
|
||||
This is implemented in :pymod:`pytest.plugin.nose`.
|
||||
This is implemented in :pymod:`_pytest.nose`.
|
||||
|
||||
Usage
|
||||
-------------
|
||||
|
|
|
@ -180,28 +180,28 @@ py.test default plugin reference
|
|||
|
||||
.. autosummary::
|
||||
|
||||
pytest.plugin.assertion
|
||||
pytest.plugin.capture
|
||||
pytest.plugin.config
|
||||
pytest.plugin.doctest
|
||||
pytest.plugin.genscript
|
||||
pytest.plugin.helpconfig
|
||||
pytest.plugin.junitxml
|
||||
pytest.plugin.mark
|
||||
pytest.plugin.monkeypatch
|
||||
pytest.plugin.nose
|
||||
pytest.plugin.pastebin
|
||||
pytest.plugin.pdb
|
||||
pytest.plugin.pytester
|
||||
pytest.plugin.python
|
||||
pytest.plugin.recwarn
|
||||
pytest.plugin.resultlog
|
||||
pytest.plugin.runner
|
||||
pytest.plugin.session
|
||||
pytest.plugin.skipping
|
||||
pytest.plugin.terminal
|
||||
pytest.plugin.tmpdir
|
||||
pytest.plugin.unittest
|
||||
_pytest.assertion
|
||||
_pytest.capture
|
||||
_pytest.config
|
||||
_pytest.doctest
|
||||
_pytest.genscript
|
||||
_pytest.helpconfig
|
||||
_pytest.junitxml
|
||||
_pytest.mark
|
||||
_pytest.monkeypatch
|
||||
_pytest.nose
|
||||
_pytest.pastebin
|
||||
_pytest.pdb
|
||||
_pytest.pytester
|
||||
_pytest.python
|
||||
_pytest.recwarn
|
||||
_pytest.resultlog
|
||||
_pytest.runner
|
||||
_pytest.session
|
||||
_pytest.skipping
|
||||
_pytest.terminal
|
||||
_pytest.tmpdir
|
||||
_pytest.unittest
|
||||
|
||||
.. _`well specified hooks`:
|
||||
|
||||
|
@ -222,7 +222,7 @@ hook name itself you get useful errors.
|
|||
initialisation, command line and configuration hooks
|
||||
--------------------------------------------------------------------
|
||||
|
||||
.. currentmodule:: pytest.hookspec
|
||||
.. currentmodule:: _pytest.hookspec
|
||||
|
||||
.. autofunction:: pytest_cmdline_parse
|
||||
.. autofunction:: pytest_namespace
|
||||
|
@ -243,11 +243,11 @@ All all runtest related hooks receive a :py:class:`pytest.Item` object.
|
|||
.. autofunction:: pytest_runtest_makereport
|
||||
|
||||
For deeper understanding you may look at the default implementation of
|
||||
these hooks in :py:mod:`pytest.plugin.runner` and maybe also
|
||||
in :py:mod:`pytest.plugin.pdb` which intercepts creation
|
||||
these hooks in :py:mod:`_pytest.runner` and maybe also
|
||||
in :py:mod:`_pytest.pdb` which intercepts creation
|
||||
of reports in order to drop to interactive debugging.
|
||||
|
||||
The :py:mod:`pytest.plugin.terminal` reported specifically uses
|
||||
The :py:mod:`_pytest.terminal` reported specifically uses
|
||||
the reporting hook to print information about a test run.
|
||||
|
||||
collection hooks
|
||||
|
@ -284,35 +284,35 @@ test execution:
|
|||
Reference of important objects involved in hooks
|
||||
===========================================================
|
||||
|
||||
.. autoclass:: pytest.plugin.config.Config
|
||||
.. autoclass:: _pytest.config.Config
|
||||
:members:
|
||||
|
||||
.. autoclass:: pytest.plugin.config.Parser
|
||||
.. autoclass:: _pytest.config.Parser
|
||||
:members:
|
||||
|
||||
.. autoclass:: pytest.plugin.session.Node(name, parent)
|
||||
.. autoclass:: _pytest.session.Node(name, parent)
|
||||
:members:
|
||||
|
||||
..
|
||||
.. autoclass:: pytest.plugin.session.File(fspath, parent)
|
||||
.. autoclass:: _pytest.session.File(fspath, parent)
|
||||
:members:
|
||||
|
||||
.. autoclass:: pytest.plugin.session.Item(name, parent)
|
||||
.. autoclass:: _pytest.session.Item(name, parent)
|
||||
:members:
|
||||
|
||||
.. autoclass:: pytest.plugin.python.Module(name, parent)
|
||||
.. autoclass:: _pytest.python.Module(name, parent)
|
||||
:members:
|
||||
|
||||
.. autoclass:: pytest.plugin.python.Class(name, parent)
|
||||
.. autoclass:: _pytest.python.Class(name, parent)
|
||||
:members:
|
||||
|
||||
.. autoclass:: pytest.plugin.python.Function(name, parent)
|
||||
.. autoclass:: _pytest.python.Function(name, parent)
|
||||
:members:
|
||||
|
||||
.. autoclass:: pytest.plugin.runner.CallInfo
|
||||
.. autoclass:: _pytest.runner.CallInfo
|
||||
:members:
|
||||
|
||||
.. autoclass:: pytest.plugin.runner.TestReport
|
||||
.. autoclass:: _pytest.runner.TestReport
|
||||
:members:
|
||||
|
||||
|
||||
|
|
|
@ -7,6 +7,19 @@ Usage and Invocations
|
|||
|
||||
.. _cmdline:
|
||||
|
||||
calling pytest through ``python -m pytest``
|
||||
-----------------------------------------------------
|
||||
|
||||
.. versionadded: 2.0
|
||||
|
||||
If you use Python-2.5 or above you can invoke testing through the
|
||||
Python interpreter from the command line::
|
||||
|
||||
python -m pytest [...]
|
||||
|
||||
This is equivalent to invoking the command line script ``py.test [...]``
|
||||
directly.
|
||||
|
||||
Getting help on version, option names, environment vars
|
||||
-----------------------------------------------------------
|
||||
|
||||
|
@ -38,23 +51,6 @@ Import 'pkg' and use its filesystem location to find and run tests::
|
|||
|
||||
py.test --pyargs pkg # run all tests found below directory of pypkg
|
||||
|
||||
calling pytest through ``python -m pytest``
|
||||
-----------------------------------------------------
|
||||
|
||||
.. versionadded: 2.0
|
||||
|
||||
You can invoke testing through the Python interpreter from the command line::
|
||||
|
||||
python -m pytest.main [...]
|
||||
|
||||
Python2.7 and Python3 introduced specifying packages to "-m" so there
|
||||
you can also type::
|
||||
|
||||
python -m pytest [...]
|
||||
|
||||
All of these invocations are equivalent to the ``py.test [...]`` command line invocation.
|
||||
|
||||
|
||||
Modifying Python traceback printing
|
||||
----------------------------------------------
|
||||
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
"""
|
||||
unit and functional testing with Python.
|
||||
|
||||
see http://pytest.org for documentation and details
|
||||
|
||||
(c) Holger Krekel and others, 2004-2010
|
||||
"""
|
||||
__version__ = '2.0.0.dev26'
|
||||
__all__ = ['main']
|
||||
|
||||
from _pytest.core import main, UsageError, _preloadplugins
|
||||
from _pytest import core as cmdline
|
||||
|
||||
if __name__ == '__main__': # if run as a script or by 'python -m pytest'
|
||||
raise SystemExit(main())
|
||||
else:
|
||||
_preloadplugins() # to populate pytest.* namespace so help(pytest) works
|
|
@ -1,14 +0,0 @@
|
|||
"""
|
||||
unit and functional testing with Python.
|
||||
|
||||
see http://pytest.org for documentation and details
|
||||
|
||||
(c) Holger Krekel and others, 2004-2010
|
||||
"""
|
||||
__version__ = '2.0.0.dev25'
|
||||
|
||||
__all__ = ['cmdline', 'collect', 'main']
|
||||
|
||||
from pytest import main as cmdline
|
||||
UsageError = cmdline.UsageError
|
||||
main = cmdline.main
|
|
@ -1,4 +0,0 @@
|
|||
import pytest
|
||||
|
||||
if __name__ == '__main__':
|
||||
raise SystemExit(pytest.main())
|
5
setup.py
5
setup.py
|
@ -22,7 +22,7 @@ def main():
|
|||
name='pytest',
|
||||
description='py.test: simple powerful testing with Python',
|
||||
long_description = long_description,
|
||||
version='2.0.0.dev25',
|
||||
version='2.0.0.dev26',
|
||||
url='http://pytest.org',
|
||||
license='MIT license',
|
||||
platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],
|
||||
|
@ -41,7 +41,8 @@ def main():
|
|||
'Topic :: Utilities',
|
||||
'Programming Language :: Python',
|
||||
'Programming Language :: Python :: 3'],
|
||||
packages=['pytest', 'pytest.plugin', ],
|
||||
packages=['_pytest', ],
|
||||
py_modules=['pytest'],
|
||||
zip_safe=False,
|
||||
)
|
||||
|
||||
|
|
|
@ -244,16 +244,30 @@ class TestInvocationVariants:
|
|||
s = result.stdout.str()
|
||||
assert 'MarkGenerator' in s
|
||||
|
||||
@pytest.mark.multi(source=['py.test', 'pytest'])
|
||||
def test_import_star(self, testdir, source):
|
||||
def test_import_star_py_dot_test(self, testdir):
|
||||
p = testdir.makepyfile("""
|
||||
from %s import *
|
||||
collect
|
||||
cmdline
|
||||
from py.test import *
|
||||
#collect
|
||||
#cmdline
|
||||
#Item
|
||||
#assert collect.Item is Item
|
||||
#assert collect.Collector is Collector
|
||||
main
|
||||
skip
|
||||
xfail
|
||||
""" % source)
|
||||
""")
|
||||
result = testdir.runpython(p)
|
||||
assert result.ret == 0
|
||||
|
||||
def test_import_star_pytest(self, testdir):
|
||||
p = testdir.makepyfile("""
|
||||
from pytest import *
|
||||
#Item
|
||||
#File
|
||||
main
|
||||
skip
|
||||
xfail
|
||||
""")
|
||||
result = testdir.runpython(p)
|
||||
assert result.ret == 0
|
||||
|
||||
|
@ -286,13 +300,6 @@ class TestInvocationVariants:
|
|||
assert res.ret == 1
|
||||
|
||||
@py.test.mark.skipif("sys.version_info < (2,5)")
|
||||
def test_python_pytest_main(self, testdir):
|
||||
p1 = testdir.makepyfile("def test_pass(): pass")
|
||||
res = testdir.run(py.std.sys.executable, "-m", "pytest.main", str(p1))
|
||||
assert res.ret == 0
|
||||
res.stdout.fnmatch_lines(["*1 passed*"])
|
||||
|
||||
@py.test.mark.skipif("sys.version_info < (2,7)")
|
||||
def test_python_pytest_package(self, testdir):
|
||||
p1 = testdir.makepyfile("def test_pass(): pass")
|
||||
res = testdir.run(py.std.sys.executable, "-m", "pytest", str(p1))
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import py
|
||||
|
||||
import pytest.plugin
|
||||
plugindir = py.path.local(pytest.plugin.__file__).dirpath()
|
||||
from pytest.main import default_plugins
|
||||
import _pytest
|
||||
plugindir = py.path.local(_pytest.__file__).dirpath()
|
||||
from _pytest.core import default_plugins
|
||||
|
||||
def pytest_collect_file(path, parent):
|
||||
if path.basename.startswith("pytest_") and path.ext == ".py":
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import sys
|
||||
|
||||
import py
|
||||
import pytest.plugin.assertion as plugin
|
||||
import _pytest.assertion as plugin
|
||||
|
||||
needsnewassert = py.test.mark.skipif("sys.version_info < (2,6)")
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import py, os, sys
|
||||
from pytest.plugin.capture import CaptureManager
|
||||
from _pytest.capture import CaptureManager
|
||||
|
||||
needsosdup = py.test.mark.xfail("not hasattr(os, 'dup')")
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from pytest.plugin.doctest import DoctestModule, DoctestTextfile
|
||||
from _pytest.doctest import DoctestModule, DoctestTextfile
|
||||
import py
|
||||
|
||||
pytest_plugins = ["pytest_doctest"]
|
||||
|
|
|
@ -22,7 +22,7 @@ def test_gen(testdir, anypython, standalone):
|
|||
result = standalone.run(anypython, testdir, '--version')
|
||||
assert result.ret == 0
|
||||
result.stderr.fnmatch_lines([
|
||||
"*imported from*mypytest"
|
||||
"*imported from*mypytest*"
|
||||
])
|
||||
p = testdir.makepyfile("def test_func(): assert 0")
|
||||
result = standalone.run(anypython, testdir, p)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import py, pytest,os
|
||||
from pytest.plugin.helpconfig import collectattr
|
||||
from _pytest.helpconfig import collectattr
|
||||
|
||||
def test_version(testdir):
|
||||
result = testdir.runpytest("--version")
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import py
|
||||
from pytest.plugin.mark import MarkGenerator as Mark
|
||||
from _pytest.mark import MarkGenerator as Mark
|
||||
|
||||
class TestMark:
|
||||
def test_pytest_mark_notcallable(self):
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import os, sys
|
||||
import py
|
||||
from pytest.plugin.monkeypatch import monkeypatch as MonkeyPatch
|
||||
from _pytest.monkeypatch import monkeypatch as MonkeyPatch
|
||||
|
||||
def test_setattr():
|
||||
class A:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import py
|
||||
import os, sys
|
||||
from pytest.plugin.pytester import LineMatcher, LineComp, HookRecorder
|
||||
from pytest.main import PluginManager
|
||||
from _pytest.pytester import LineMatcher, LineComp, HookRecorder
|
||||
from _pytest.core import PluginManager
|
||||
|
||||
def test_reportrecorder(testdir):
|
||||
item = testdir.getitem("def test_func(): pass")
|
||||
|
@ -97,7 +97,7 @@ def test_hookrecorder_basic_no_args_hook():
|
|||
def test_functional(testdir, linecomp):
|
||||
reprec = testdir.inline_runsource("""
|
||||
import py
|
||||
from pytest.main import HookRelay, PluginManager
|
||||
from _pytest.core import HookRelay, PluginManager
|
||||
pytest_plugins="pytester"
|
||||
def test_func(_pytest):
|
||||
class ApiClass:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import pytest, py, sys
|
||||
from pytest.plugin import python as funcargs
|
||||
from _pytest import python as funcargs
|
||||
|
||||
class TestModule:
|
||||
def test_failing_import(self, testdir):
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import py
|
||||
from pytest.plugin.recwarn import WarningsRecorder
|
||||
from _pytest.recwarn import WarningsRecorder
|
||||
|
||||
def test_WarningRecorder(recwarn):
|
||||
showwarning = py.std.warnings.showwarning
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import py
|
||||
import os
|
||||
from pytest.plugin.resultlog import generic_path, ResultLog, \
|
||||
from _pytest.resultlog import generic_path, ResultLog, \
|
||||
pytest_configure, pytest_unconfigure
|
||||
from pytest.plugin.session import Node, Item, FSCollector
|
||||
from _pytest.session import Node, Item, FSCollector
|
||||
|
||||
def test_generic_path(testdir):
|
||||
from pytest.plugin.session import Session
|
||||
from _pytest.session import Session
|
||||
config = testdir.parseconfig()
|
||||
session = Session(config)
|
||||
p1 = Node('a', config=config, session=session)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import py, sys
|
||||
from pytest.plugin import runner
|
||||
from _pytest import runner
|
||||
from py._code.code import ReprExceptionInfo
|
||||
|
||||
class TestSetupState:
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import py
|
||||
|
||||
from pytest.plugin.skipping import MarkEvaluator, folded_skips
|
||||
from pytest.plugin.skipping import pytest_runtest_setup
|
||||
from pytest.plugin.runner import runtestprotocol
|
||||
from _pytest.skipping import MarkEvaluator, folded_skips
|
||||
from _pytest.skipping import pytest_runtest_setup
|
||||
from _pytest.runner import runtestprotocol
|
||||
|
||||
class TestEvaluator:
|
||||
def test_no_marker(self, testdir):
|
||||
|
|
|
@ -4,9 +4,9 @@ terminal reporting of the full testing process.
|
|||
import pytest,py
|
||||
import sys
|
||||
|
||||
from pytest.plugin.terminal import TerminalReporter, \
|
||||
from _pytest.terminal import TerminalReporter, \
|
||||
CollectonlyReporter, repr_pythonversion, getreportopt
|
||||
from pytest.plugin import runner
|
||||
from _pytest import runner
|
||||
|
||||
def basic_run_report(item):
|
||||
runner.call_and_report(item, "setup", log=False)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import py
|
||||
|
||||
from pytest.plugin.tmpdir import pytest_funcarg__tmpdir
|
||||
from pytest.plugin.python import FuncargRequest
|
||||
from _pytest.tmpdir import pytest_funcarg__tmpdir
|
||||
from _pytest.python import FuncargRequest
|
||||
|
||||
def test_funcarg(testdir):
|
||||
item = testdir.getitem("""
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import pytest, py
|
||||
|
||||
from pytest.plugin.session import Session
|
||||
from _pytest.session import Session
|
||||
|
||||
class TestCollector:
|
||||
def test_collect_versus_item(self):
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import py
|
||||
|
||||
from pytest.plugin.config import getcfg, Config
|
||||
from _pytest.config import getcfg, Config
|
||||
|
||||
class TestParseIni:
|
||||
def test_getcfg_and_config(self, tmpdir):
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import py
|
||||
from pytest.plugin.config import Conftest
|
||||
from _pytest.config import Conftest
|
||||
|
||||
def pytest_generate_tests(metafunc):
|
||||
if "basedir" in metafunc.funcargnames:
|
||||
|
@ -110,7 +110,7 @@ def test_conftest_global_import(testdir):
|
|||
testdir.makeconftest("x=3")
|
||||
p = testdir.makepyfile("""
|
||||
import py
|
||||
from pytest.plugin.config import Conftest
|
||||
from _pytest.config import Conftest
|
||||
conf = Conftest()
|
||||
mod = conf.importconftest(py.path.local("conftest.py"))
|
||||
assert mod.x == 3
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import py, os
|
||||
from pytest.main import PluginManager, canonical_importname
|
||||
from pytest.main import MultiCall, HookRelay, varnames
|
||||
from _pytest.core import PluginManager, canonical_importname
|
||||
from _pytest.core import MultiCall, HookRelay, varnames
|
||||
|
||||
|
||||
class TestBootstrapping:
|
||||
|
@ -560,7 +560,7 @@ class TestHookRelay:
|
|||
|
||||
class TestTracer:
|
||||
def test_simple(self):
|
||||
from pytest.main import TagTracer
|
||||
from _pytest.core import TagTracer
|
||||
rootlogger = TagTracer("[my] ")
|
||||
log = rootlogger.get("pytest")
|
||||
log("hello")
|
||||
|
@ -574,7 +574,7 @@ class TestTracer:
|
|||
assert l[1] == "[my] hello\n"
|
||||
|
||||
def test_indent(self):
|
||||
from pytest.main import TagTracer
|
||||
from _pytest.core import TagTracer
|
||||
rootlogger = TagTracer()
|
||||
log = rootlogger.get("1")
|
||||
l = []
|
||||
|
@ -596,7 +596,7 @@ class TestTracer:
|
|||
' line3', ' line4', ' line5', 'last']
|
||||
|
||||
def test_setprocessor(self):
|
||||
from pytest.main import TagTracer
|
||||
from _pytest.core import TagTracer
|
||||
rootlogger = TagTracer()
|
||||
log = rootlogger.get("1")
|
||||
log2 = log.get("2")
|
||||
|
@ -618,7 +618,7 @@ class TestTracer:
|
|||
|
||||
|
||||
def test_setmyprocessor(self):
|
||||
from pytest.main import TagTracer
|
||||
from _pytest.core import TagTracer
|
||||
rootlogger = TagTracer()
|
||||
log = rootlogger.get("1")
|
||||
log2 = log.get("2")
|
|
@ -1,5 +1,5 @@
|
|||
import py
|
||||
from pytest.plugin import config as parseopt
|
||||
from _pytest import config as parseopt
|
||||
from textwrap import dedent
|
||||
|
||||
class TestParser:
|
||||
|
|
Loading…
Reference in New Issue