internally switch to pytest.plugin.NAME instead of pytest.plugin.pytest_NAME

--HG--
branch : trunk
This commit is contained in:
holger krekel 2010-10-11 01:14:40 +02:00
parent ce3b260b0b
commit eee0e14334
55 changed files with 36 additions and 102 deletions

View File

@ -2,7 +2,7 @@
funcargs: creating and managing test function arguments
==============================================================
.. currentmodule:: pytest.plugin.pytest_python
.. currentmodule:: pytest.plugin.python
.. _`funcarg mechanism`:

View File

@ -2,7 +2,7 @@
monkeypatching/mocking modules and environments
================================================================
.. currentmodule:: pytest.plugin.pytest_monkeypatch
.. currentmodule:: pytest.plugin.monkeypatch
Sometimes tests need to invoke functionality which depends
on global settings or which invokes code which cannot be easily

View File

@ -1,30 +1,8 @@
"""
collect and execute doctests from modules and test files.
Usage
-------------
By default all files matching the ``test*.txt`` pattern will
be run through the python standard ``doctest`` module. Issue::
py.test --doctest-glob='*.rst'
to change the pattern. Additionally you can trigger running of
tests in all python modules (including regular python test modules)::
py.test --doctest-modules
You can also make these changes permanent in your project by
putting them into a conftest.py file like this::
# content of conftest.py
option_doctestmodules = True
option_doctestglob = "*.rst"
"""
""" collect and execute doctests from modules and test files."""
import py
from py._code.code import TerminalRepr, ReprFileLocation
import doctest
doctest = py.std.doctest
def pytest_addoption(parser):
group = parser.getgroup("collect")

View File

@ -1,33 +0,0 @@
""" log invocations of extension hooks to a file. """
import py
def pytest_addoption(parser):
parser.addoption("--hooklog", dest="hooklog", default=None,
help="write hook calls to the given file.")
def pytest_configure(config):
hooklog = config.getvalue("hooklog")
if hooklog:
config._hooklogfile = open(hooklog, 'w')
config._hooklog_oldperformcall = config.hook._performcall
config.hook._performcall = (lambda name, multicall:
logged_call(name=name, multicall=multicall, config=config))
def logged_call(name, multicall, config):
f = config._hooklogfile
f.write("%s(**%s)\n" % (name, multicall.kwargs))
try:
res = config._hooklog_oldperformcall(name=name, multicall=multicall)
except:
f.write("-> exception")
raise
f.write("-> %r" % (res,))
return res
def pytest_unconfigure(config):
try:
del config.hook.__dict__['_performcall']
except KeyError:
pass
else:
config._hooklogfile.close()

View File

@ -9,7 +9,7 @@ import inspect
import time
from fnmatch import fnmatch
from pytest._config import Config as pytestConfig
from pytest.plugin.pytest_session import Collection
from pytest.plugin.session import Collection
from py.builtin import print_
def pytest_addoption(parser):

View File

@ -697,7 +697,7 @@ class FuncargRequest:
raise self.LookupError(msg)
def showfuncargs(config):
from pytest.plugin.pytest_session import Collection
from pytest.plugin.session import Collection
collection = Collection(config)
firstid = collection._normalizearg(config.args[0])
colitem = collection.getbyid(firstid)[0]

View File

@ -142,7 +142,7 @@ class PluginManager(object):
self._hints.append("skipped plugin %r: %s" %((modname, e.msg)))
else:
check_old_use(mod, modname)
self.register(mod)
self.register(mod, modname)
self.consider_module(mod)
def pytest_terminal_summary(self, terminalreporter):
@ -225,12 +225,14 @@ def importplugin(importspec):
e = py.std.sys.exc_info()[1]
if str(e).find(importspec) == -1:
raise
name = importspec
try:
return __import__("pytest.plugin.%s" %(importspec),
None, None, '__doc__')
if name.startswith("pytest_"):
name = importspec[7:]
return __import__("pytest.plugin.%s" %(name), None, None, '__doc__')
except ImportError:
e = py.std.sys.exc_info()[1]
if str(e).find(importspec) == -1:
if str(e).find(name) == -1:
raise
# show the original exception, not the failing internal one
return __import__(importspec)

View File

@ -1,7 +1,7 @@
import sys
import py
import pytest.plugin.pytest_assertion as plugin
import pytest.plugin.assertion as plugin
needsnewassert = py.test.mark.skipif("sys.version_info < (2,6)")

View File

@ -1,5 +1,5 @@
import py, os, sys
from pytest.plugin.pytest_capture import CaptureManager
from pytest.plugin.capture import CaptureManager
needsosdup = py.test.mark.xfail("not hasattr(os, 'dup')")

View File

@ -1,4 +1,4 @@
from pytest.plugin.pytest_doctest import DoctestModule, DoctestTextfile
from pytest.plugin.doctest import DoctestModule, DoctestTextfile
import py
pytest_plugins = ["pytest_doctest"]

View File

@ -1,5 +1,5 @@
import py, os
from pytest.plugin.pytest_helpconfig import collectattr
from pytest.plugin.helpconfig import collectattr
def test_version(testdir):
assert py.version == py.__version__

View File

@ -1,5 +1,5 @@
import py
from pytest.plugin.pytest_mark import MarkGenerator as Mark
from pytest.plugin.mark import MarkGenerator as Mark
class TestMark:
def test_pytest_mark_notcallable(self):

View File

@ -1,6 +1,6 @@
import os, sys
import py
from pytest.plugin.pytest_monkeypatch import monkeypatch as MonkeyPatch
from pytest.plugin.monkeypatch import monkeypatch as MonkeyPatch
def test_setattr():
class A:

View File

@ -1,6 +1,6 @@
import py
import os, sys
from pytest.plugin.pytest__pytest import HookRecorder
from pytest.plugin._pytest import HookRecorder
from pytest.pluginmanager import Registry
def test_hookrecorder_basic():

View File

@ -1,12 +0,0 @@
import py
def test_functional(testdir):
testdir.makepyfile("""
def test_pass():
pass
""")
testdir.runpytest("--hooklog=hook.log")
s = testdir.tmpdir.join("hook.log").read()
assert s.find("pytest_sessionstart") != -1
assert s.find("TestReport") != -1
assert s.find("sessionfinish") != -1

View File

@ -1,5 +1,5 @@
import py
from pytest.plugin.pytest_pytester import LineMatcher, LineComp
from pytest.plugin.pytester import LineMatcher, LineComp
def test_reportrecorder(testdir):
item = testdir.getitem("def test_func(): pass")

View File

@ -1,5 +1,5 @@
import py, sys
from pytest.plugin import pytest_python as funcargs
from pytest.plugin import python as funcargs
class TestModule:
def test_module_file_not_found(self, testdir):

View File

@ -1,5 +1,5 @@
import py
from pytest.plugin.pytest_recwarn import WarningsRecorder
from pytest.plugin.recwarn import WarningsRecorder
def test_WarningRecorder(recwarn):
showwarning = py.std.warnings.showwarning

View File

@ -1,5 +1,5 @@
import py
from pytest.plugin.pytest_restdoc import deindent
from pytest.plugin.restdoc import deindent
def test_deindent():
assert deindent('foo') == 'foo'
@ -18,7 +18,7 @@ class TestDoctest:
testdir.plugins.append("restdoc")
assert request.module.__name__ == __name__
testdir.makepyfile(confrest=
"from pytest.plugin.pytest_restdoc import Project")
"from pytest.plugin.restdoc import Project")
# we scope our confrest file so that it doesn't
# conflict with another global confrest.py
testdir.makepyfile(__init__="")

View File

@ -1,11 +1,11 @@
import py
import os
from pytest.plugin.pytest_resultlog import generic_path, ResultLog, \
from pytest.plugin.resultlog import generic_path, ResultLog, \
pytest_configure, pytest_unconfigure
from pytest.collect import Node, Item, FSCollector
def test_generic_path(testdir):
from pytest.plugin.pytest_session import Collection
from pytest.plugin.session import Collection
config = testdir.parseconfig()
collection = Collection(config)
p1 = Node('a', config=config, collection=collection)

View File

@ -1,5 +1,5 @@
import py, sys
from pytest.plugin import pytest_runner as runner
from pytest.plugin import runner
from py._code.code import ReprExceptionInfo
class TestSetupState:

View File

@ -1,5 +1,5 @@
import py
from pytest.plugin.pytest_session import pytest_report_iteminfo
from pytest.plugin.session import pytest_report_iteminfo
class SessionTests:
def test_basic_testitem_events(self, testdir):

View File

@ -1,8 +1,8 @@
import py
from pytest.plugin.pytest_skipping import MarkEvaluator
from pytest.plugin.pytest_skipping import pytest_runtest_setup
from pytest.plugin.pytest_runner import runtestprotocol
from pytest.plugin.skipping import MarkEvaluator, folded_skips
from pytest.plugin.skipping import pytest_runtest_setup
from pytest.plugin.runner import runtestprotocol
class TestEvaluator:
def test_no_marker(self, testdir):
@ -366,7 +366,6 @@ def test_skipif_class(testdir):
def test_skip_reasons_folding():
from pytest.plugin.pytest_skipping import folded_skips
class longrepr:
class reprcrash:
path = 'xyz'

View File

@ -9,9 +9,9 @@ import sys
#
# ===============================================================================
from pytest.plugin.pytest_terminal import TerminalReporter, \
from pytest.plugin.terminal import TerminalReporter, \
CollectonlyReporter, repr_pythonversion, getreportopt
from pytest.plugin import pytest_runner as runner
from pytest.plugin import runner
def basic_run_report(item):
runner.call_and_report(item, "setup", log=False)

View File

@ -1,7 +1,7 @@
import py
from pytest.plugin.pytest_tmpdir import pytest_funcarg__tmpdir
from pytest.plugin.pytest_python import FuncargRequest
from pytest.plugin.tmpdir import pytest_funcarg__tmpdir
from pytest.plugin.python import FuncargRequest
def test_funcarg(testdir):
item = testdir.getitem("def test_func(tmpdir): pass")

View File

@ -1,6 +1,6 @@
import py
from pytest.plugin.pytest_session import Collection, gettopdir
from pytest.plugin.session import Collection, gettopdir
class TestCollection:
def test_parsearg(self, testdir):