rewrote the initpkg mechanism and moved py lib implementation files to
_py/... with py/__init__.py containing pointers into them The new apipkg is only around 70 lines of code and allows us to get rid of the infamous "py.__." by regular non-magical "_py." imports. It is also available as a separately installable package, see http://bitbucket.org/hpk42/apipkg --HG-- branch : trunk
This commit is contained in:
parent
db1ff48996
commit
5791c06bf2
|
@ -5,6 +5,8 @@ py lib plugins and plugin call management
|
||||||
import py
|
import py
|
||||||
import inspect
|
import inspect
|
||||||
|
|
||||||
|
__all__ = ['Registry', 'MultiCall', 'comregistry', 'HookRelay']
|
||||||
|
|
||||||
class MultiCall:
|
class MultiCall:
|
||||||
""" execute a call into multiple python functions/methods. """
|
""" execute a call into multiple python functions/methods. """
|
||||||
|
|
|
@ -9,7 +9,7 @@ prepended."""
|
||||||
|
|
||||||
import sys, os
|
import sys, os
|
||||||
import py
|
import py
|
||||||
from py.__.io.terminalwriter import ansi_print, terminal_width
|
from _py.io.terminalwriter import ansi_print, terminal_width
|
||||||
import re
|
import re
|
||||||
|
|
||||||
def rec(p):
|
def rec(p):
|
|
@ -35,8 +35,8 @@ parser.add_option("--debug", action="store_true", dest="debug",
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
try:
|
try:
|
||||||
from py.__.rest import directive, resthtml
|
from _py.rest import directive, resthtml
|
||||||
from py.__.rest.latex import process_rest_file, process_configfile
|
from _py.rest.latex import process_rest_file, process_configfile
|
||||||
except ImportError:
|
except ImportError:
|
||||||
e = sys.exc_info()[1]
|
e = sys.exc_info()[1]
|
||||||
print(str(e))
|
print(str(e))
|
|
@ -7,7 +7,7 @@ import sys
|
||||||
import ast
|
import ast
|
||||||
|
|
||||||
import py
|
import py
|
||||||
from py.__.code.assertion import _format_explanation, BuiltinAssertionError
|
from _py.code.assertion import _format_explanation, BuiltinAssertionError
|
||||||
|
|
||||||
|
|
||||||
class Failure(Exception):
|
class Failure(Exception):
|
|
@ -1,7 +1,7 @@
|
||||||
import py
|
import py
|
||||||
import sys, inspect
|
import sys, inspect
|
||||||
from compiler import parse, ast, pycodegen
|
from compiler import parse, ast, pycodegen
|
||||||
from py.__.code.assertion import BuiltinAssertionError, _format_explanation
|
from _py.code.assertion import BuiltinAssertionError, _format_explanation
|
||||||
|
|
||||||
passthroughex = (KeyboardInterrupt, SystemExit, MemoryError)
|
passthroughex = (KeyboardInterrupt, SystemExit, MemoryError)
|
||||||
|
|
|
@ -38,9 +38,9 @@ def _format_explanation(explanation):
|
||||||
|
|
||||||
|
|
||||||
if sys.version_info >= (2, 6):
|
if sys.version_info >= (2, 6):
|
||||||
from py.__.code._assertionnew import interpret
|
from _py.code._assertionnew import interpret
|
||||||
else:
|
else:
|
||||||
from py.__.code._assertionold import interpret
|
from _py.code._assertionold import interpret
|
||||||
|
|
||||||
|
|
||||||
class AssertionError(BuiltinAssertionError):
|
class AssertionError(BuiltinAssertionError):
|
|
@ -84,7 +84,7 @@ class Code(object):
|
||||||
def fullsource(self):
|
def fullsource(self):
|
||||||
""" return a py.code.Source object for the full source file of the code
|
""" return a py.code.Source object for the full source file of the code
|
||||||
"""
|
"""
|
||||||
from py.__.code import source
|
from _py.code import source
|
||||||
full, _ = source.findsource(self.raw)
|
full, _ = source.findsource(self.raw)
|
||||||
return full
|
return full
|
||||||
fullsource = property(fullsource, None, None,
|
fullsource = property(fullsource, None, None,
|
||||||
|
@ -196,7 +196,7 @@ class TracebackEntry(object):
|
||||||
"""Reinterpret the failing statement and returns a detailed information
|
"""Reinterpret the failing statement and returns a detailed information
|
||||||
about what operations are performed."""
|
about what operations are performed."""
|
||||||
if self.exprinfo is None:
|
if self.exprinfo is None:
|
||||||
from py.__.code import assertion
|
from _py.code import assertion
|
||||||
source = str(self.statement).strip()
|
source = str(self.statement).strip()
|
||||||
x = assertion.interpret(source, self.frame, should_fail=True)
|
x = assertion.interpret(source, self.frame, should_fail=True)
|
||||||
if not isinstance(x, str):
|
if not isinstance(x, str):
|
||||||
|
@ -738,7 +738,7 @@ oldbuiltins = {}
|
||||||
def patch_builtins(assertion=True, compile=True):
|
def patch_builtins(assertion=True, compile=True):
|
||||||
""" put compile and AssertionError builtins to Python's builtins. """
|
""" put compile and AssertionError builtins to Python's builtins. """
|
||||||
if assertion:
|
if assertion:
|
||||||
from py.__.code import assertion
|
from _py.code import assertion
|
||||||
l = oldbuiltins.setdefault('AssertionError', [])
|
l = oldbuiltins.setdefault('AssertionError', [])
|
||||||
l.append(py.builtin.builtins.AssertionError)
|
l.append(py.builtin.builtins.AssertionError)
|
||||||
py.builtin.builtins.AssertionError = assertion.AssertionError
|
py.builtin.builtins.AssertionError = assertion.AssertionError
|
|
@ -1,5 +1,5 @@
|
||||||
import py, itertools
|
import py, itertools
|
||||||
from py.__.path import common
|
from _py.path import common
|
||||||
|
|
||||||
COUNTER = itertools.count()
|
COUNTER = itertools.count()
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
"""
|
"""
|
||||||
local path implementation.
|
local path implementation.
|
||||||
"""
|
"""
|
||||||
from __future__ import generators
|
|
||||||
import sys, os, stat, re, atexit
|
import sys, os, stat, re, atexit
|
||||||
import py
|
import py
|
||||||
from py.__.path import common
|
from _py.path import common
|
||||||
|
|
||||||
iswin32 = sys.platform == "win32"
|
iswin32 = sys.platform == "win32"
|
||||||
|
|
||||||
|
@ -508,16 +507,9 @@ class LocalPath(FSBase):
|
||||||
if ensuresyspath:
|
if ensuresyspath:
|
||||||
self._prependsyspath(pkgpath.dirpath())
|
self._prependsyspath(pkgpath.dirpath())
|
||||||
pkg = __import__(pkgpath.basename, None, None, [])
|
pkg = __import__(pkgpath.basename, None, None, [])
|
||||||
|
names = self.new(ext='').relto(pkgpath.dirpath())
|
||||||
if hasattr(pkg, '__pkg__'):
|
names = names.split(self.sep)
|
||||||
modname = pkg.__pkg__.getimportname(self)
|
modname = ".".join(names)
|
||||||
assert modname is not None, "package %s doesn't know %s" % (
|
|
||||||
pkg.__name__, self)
|
|
||||||
|
|
||||||
else:
|
|
||||||
names = self.new(ext='').relto(pkgpath.dirpath())
|
|
||||||
names = names.split(self.sep)
|
|
||||||
modname = ".".join(names)
|
|
||||||
else:
|
else:
|
||||||
# no package scope, still make it possible
|
# no package scope, still make it possible
|
||||||
if ensuresyspath:
|
if ensuresyspath:
|
|
@ -7,9 +7,9 @@ but might also interact well with earlier versions.
|
||||||
import os, sys, time, re
|
import os, sys, time, re
|
||||||
import py
|
import py
|
||||||
from py import path, process
|
from py import path, process
|
||||||
from py.__.path import common
|
from _py.path import common
|
||||||
from py.__.path import svnwc as svncommon
|
from _py.path import svnwc as svncommon
|
||||||
from py.__.path.cacheutil import BuildcostAccessCache, AgingCache
|
from _py.path.cacheutil import BuildcostAccessCache, AgingCache
|
||||||
|
|
||||||
DEBUG=False
|
DEBUG=False
|
||||||
|
|
|
@ -8,7 +8,7 @@ svn-Command based Implementation of a Subversion WorkingCopy Path.
|
||||||
import os, sys, time, re, calendar
|
import os, sys, time, re, calendar
|
||||||
import py
|
import py
|
||||||
import subprocess
|
import subprocess
|
||||||
from py.__.path import common
|
from _py.path import common
|
||||||
|
|
||||||
#-----------------------------------------------------------
|
#-----------------------------------------------------------
|
||||||
# Caching latest repository revision and repo-paths
|
# Caching latest repository revision and repo-paths
|
|
@ -1,6 +1,6 @@
|
||||||
import py
|
import py
|
||||||
|
|
||||||
from py.__.process.cmdexec import ExecutionFailed
|
from _py.process.cmdexec import ExecutionFailed
|
||||||
# utility functions to convert between various formats
|
# utility functions to convert between various formats
|
||||||
|
|
||||||
format_to_dotargument = {"png": "png",
|
format_to_dotargument = {"png": "png",
|
|
@ -1,7 +1,7 @@
|
||||||
# XXX this file is messy since it tries to deal with several docutils versions
|
# XXX this file is messy since it tries to deal with several docutils versions
|
||||||
import py
|
import py
|
||||||
|
|
||||||
from py.__.rest.convert import convert_dot, latexformula2png
|
from _py.rest.convert import convert_dot, latexformula2png
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import docutils
|
import docutils
|
|
@ -1,6 +1,6 @@
|
||||||
import py
|
import py
|
||||||
|
|
||||||
from py.__.process.cmdexec import ExecutionFailed
|
from _py.process.cmdexec import ExecutionFailed
|
||||||
|
|
||||||
font_to_package = {"times": "times", "helvetica": "times",
|
font_to_package = {"times": "times", "helvetica": "times",
|
||||||
"new century schoolbock": "newcent", "avant garde": "newcent",
|
"new century schoolbock": "newcent", "avant garde": "newcent",
|
|
@ -10,7 +10,7 @@ else:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def convert_rest_html(source, source_path, stylesheet=None, encoding='latin1'):
|
def convert_rest_html(source, source_path, stylesheet=None, encoding='latin1'):
|
||||||
from py.__.rest import directive
|
from _py.rest import directive
|
||||||
""" return html latin1-encoded document for the given input.
|
""" return html latin1-encoded document for the given input.
|
||||||
source a ReST-string
|
source a ReST-string
|
||||||
sourcepath where to look for includes (basically)
|
sourcepath where to look for includes (basically)
|
|
@ -4,7 +4,7 @@ Collectors and test Items form a tree
|
||||||
that is usually built iteratively.
|
that is usually built iteratively.
|
||||||
"""
|
"""
|
||||||
import py
|
import py
|
||||||
pydir = py.path.local(py.__file__).dirpath()
|
pydir = py.path.local(py._py.__file__).dirpath()
|
||||||
|
|
||||||
def configproperty(name):
|
def configproperty(name):
|
||||||
def fget(self):
|
def fget(self):
|
|
@ -1,7 +1,7 @@
|
||||||
import py, os
|
import py, os
|
||||||
from py.__.test.conftesthandle import Conftest
|
from _py.test.conftesthandle import Conftest
|
||||||
|
|
||||||
from py.__.test import parseopt
|
from _py.test import parseopt
|
||||||
|
|
||||||
def ensuretemp(string, dir=1):
|
def ensuretemp(string, dir=1):
|
||||||
""" return temporary directory path with
|
""" return temporary directory path with
|
||||||
|
@ -221,7 +221,7 @@ class Config(object):
|
||||||
""" return an initialized session object. """
|
""" return an initialized session object. """
|
||||||
cls = self._sessionclass
|
cls = self._sessionclass
|
||||||
if cls is None:
|
if cls is None:
|
||||||
from py.__.test.session import Session
|
from _py.test.session import Session
|
||||||
cls = Session
|
cls = Session
|
||||||
session = cls(self)
|
session = cls(self)
|
||||||
self.trace("instantiated session %r" % session)
|
self.trace("instantiated session %r" % session)
|
||||||
|
@ -261,17 +261,15 @@ class Config(object):
|
||||||
conftestroots = config.getconftest_pathlist("rsyncdirs")
|
conftestroots = config.getconftest_pathlist("rsyncdirs")
|
||||||
if conftestroots:
|
if conftestroots:
|
||||||
roots.extend(conftestroots)
|
roots.extend(conftestroots)
|
||||||
pydir = py.path.local(py.__file__).dirpath()
|
pydirs = [py.path.local(x).dirpath()
|
||||||
|
for x in (py.__file__, py._py.__file__)]
|
||||||
roots = [py.path.local(root) for root in roots]
|
roots = [py.path.local(root) for root in roots]
|
||||||
for root in roots:
|
for root in roots:
|
||||||
if not root.check():
|
if not root.check():
|
||||||
raise config.Error("rsyncdir doesn't exist: %r" %(root,))
|
raise config.Error("rsyncdir doesn't exist: %r" %(root,))
|
||||||
if pydir is not None and root.basename == "py":
|
if pydirs is not None and root.basename in ("py", "_py"):
|
||||||
if root != pydir:
|
pydirs.remove(root) # otherwise it's a conflict
|
||||||
raise config.Error("root %r conflicts with imported %r" %(root, pydir))
|
roots.extend(pydirs)
|
||||||
pydir = None
|
|
||||||
if pydir is not None:
|
|
||||||
roots.append(pydir)
|
|
||||||
return roots
|
return roots
|
||||||
|
|
||||||
#
|
#
|
|
@ -5,9 +5,9 @@
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import py
|
import py
|
||||||
from py.__.test.session import Session
|
from _py.test.session import Session
|
||||||
from py.__.test import outcome
|
from _py.test import outcome
|
||||||
from py.__.test.dist.nodemanage import NodeManager
|
from _py.test.dist.nodemanage import NodeManager
|
||||||
queue = py.builtin._tryimport('queue', 'Queue')
|
queue = py.builtin._tryimport('queue', 'Queue')
|
||||||
|
|
||||||
debug_file = None # open('/tmp/loop.log', 'w')
|
debug_file = None # open('/tmp/loop.log', 'w')
|
|
@ -1,7 +1,7 @@
|
||||||
import py
|
import py
|
||||||
import sys, os
|
import sys, os
|
||||||
from py.__.test.dist.txnode import TXNode
|
from _py.test.dist.txnode import TXNode
|
||||||
from py.__.test.dist.gwmanage import GatewayManager
|
from _py.test.dist.gwmanage import GatewayManager
|
||||||
|
|
||||||
|
|
||||||
class NodeManager(object):
|
class NodeManager(object):
|
|
@ -2,7 +2,7 @@
|
||||||
Manage setup, running and local representation of remote nodes/processes.
|
Manage setup, running and local representation of remote nodes/processes.
|
||||||
"""
|
"""
|
||||||
import py
|
import py
|
||||||
from py.__.test.dist.mypickle import PickleChannel
|
from _py.test.dist.mypickle import PickleChannel
|
||||||
|
|
||||||
class TXNode(object):
|
class TXNode(object):
|
||||||
""" Represents a Test Execution environment in the controlling process.
|
""" Represents a Test Execution environment in the controlling process.
|
||||||
|
@ -84,8 +84,8 @@ def install_slave(gateway, config):
|
||||||
channel = gateway.remote_exec(source="""
|
channel = gateway.remote_exec(source="""
|
||||||
import os, sys
|
import os, sys
|
||||||
sys.path.insert(0, os.getcwd())
|
sys.path.insert(0, os.getcwd())
|
||||||
from py.__.test.dist.mypickle import PickleChannel
|
from _py.test.dist.mypickle import PickleChannel
|
||||||
from py.__.test.dist.txnode import SlaveNode
|
from _py.test.dist.txnode import SlaveNode
|
||||||
channel = PickleChannel(channel)
|
channel = PickleChannel(channel)
|
||||||
slavenode = SlaveNode(channel)
|
slavenode = SlaveNode(channel)
|
||||||
slavenode.run()
|
slavenode.run()
|
|
@ -10,9 +10,9 @@
|
||||||
import py
|
import py
|
||||||
import sys
|
import sys
|
||||||
import execnet
|
import execnet
|
||||||
from py.__.test.session import Session
|
from _py.test.session import Session
|
||||||
from py.__.test.dist.mypickle import PickleChannel
|
from _py.test.dist.mypickle import PickleChannel
|
||||||
from py.__.test.looponfail import util
|
from _py.test.looponfail import util
|
||||||
|
|
||||||
class LooponfailingSession(Session):
|
class LooponfailingSession(Session):
|
||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
|
@ -68,8 +68,8 @@ class RemoteControl(object):
|
||||||
finally:
|
finally:
|
||||||
old.chdir()
|
old.chdir()
|
||||||
channel = self.gateway.remote_exec(source="""
|
channel = self.gateway.remote_exec(source="""
|
||||||
from py.__.test.dist.mypickle import PickleChannel
|
from _py.test.dist.mypickle import PickleChannel
|
||||||
from py.__.test.looponfail.remote import slave_runsession
|
from _py.test.looponfail.remote import slave_runsession
|
||||||
outchannel = channel.gateway.newchannel()
|
outchannel = channel.gateway.newchannel()
|
||||||
channel.send(outchannel)
|
channel.send(outchannel)
|
||||||
channel = PickleChannel(channel)
|
channel = PickleChannel(channel)
|
|
@ -120,12 +120,12 @@ def fixoptions(config):
|
||||||
def setsession(config):
|
def setsession(config):
|
||||||
val = config.getvalue
|
val = config.getvalue
|
||||||
if val("collectonly"):
|
if val("collectonly"):
|
||||||
from py.__.test.session import Session
|
from _py.test.session import Session
|
||||||
config.setsessionclass(Session)
|
config.setsessionclass(Session)
|
||||||
elif execnet:
|
elif execnet:
|
||||||
if val("looponfail"):
|
if val("looponfail"):
|
||||||
from py.__.test.looponfail.remote import LooponfailingSession
|
from _py.test.looponfail.remote import LooponfailingSession
|
||||||
config.setsessionclass(LooponfailingSession)
|
config.setsessionclass(LooponfailingSession)
|
||||||
elif val("dist") != "no":
|
elif val("dist") != "no":
|
||||||
from py.__.test.dist.dsession import DSession
|
from _py.test.dist.dsession import DSession
|
||||||
config.setsessionclass(DSession)
|
config.setsessionclass(DSession)
|
|
@ -14,7 +14,7 @@ as well.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import py
|
import py
|
||||||
from py.__.code.code import TerminalRepr, ReprFileLocation
|
from _py.code.code import TerminalRepr, ReprFileLocation
|
||||||
import doctest
|
import doctest
|
||||||
|
|
||||||
def pytest_addoption(parser):
|
def pytest_addoption(parser):
|
|
@ -3,7 +3,7 @@ interactive debugging with the Python Debugger.
|
||||||
"""
|
"""
|
||||||
import py
|
import py
|
||||||
import pdb, sys, linecache
|
import pdb, sys, linecache
|
||||||
from py.__.test.outcome import Skipped
|
from _py.test.outcome import Skipped
|
||||||
try:
|
try:
|
||||||
import execnet
|
import execnet
|
||||||
except ImportError:
|
except ImportError:
|
|
@ -5,8 +5,8 @@ funcargs and support code for testing py.test's own functionality.
|
||||||
import py
|
import py
|
||||||
import sys, os
|
import sys, os
|
||||||
import inspect
|
import inspect
|
||||||
from py.__.test.config import Config as pytestConfig
|
from _py.test.config import Config as pytestConfig
|
||||||
from py.__.test.plugin import hookspec
|
from _py.test.plugin import hookspec
|
||||||
from py.builtin import print_
|
from py.builtin import print_
|
||||||
|
|
||||||
pytest_plugins = '_pytest'
|
pytest_plugins = '_pytest'
|
|
@ -87,7 +87,7 @@ class ReSTSyntaxTest(py.test.collect.Item):
|
||||||
py.test.fail("docutils processing failed, see captured stderr")
|
py.test.fail("docutils processing failed, see captured stderr")
|
||||||
|
|
||||||
def register_linkrole(self):
|
def register_linkrole(self):
|
||||||
from py.__.rest import directive
|
from _py.rest import directive
|
||||||
directive.register_linkrole('api', self.resolve_linkrole)
|
directive.register_linkrole('api', self.resolve_linkrole)
|
||||||
directive.register_linkrole('source', self.resolve_linkrole)
|
directive.register_linkrole('source', self.resolve_linkrole)
|
||||||
|
|
|
@ -3,7 +3,7 @@ collect and run test items and create reports.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import py
|
import py
|
||||||
from py.__.test.outcome import Skipped
|
from _py.test.outcome import Skipped
|
||||||
|
|
||||||
#
|
#
|
||||||
# pytest plugin hooks
|
# pytest plugin hooks
|
||||||
|
@ -118,7 +118,7 @@ def forked_run_report(item):
|
||||||
# for now, we run setup/teardown in the subprocess
|
# for now, we run setup/teardown in the subprocess
|
||||||
# XXX optionally allow sharing of setup/teardown
|
# XXX optionally allow sharing of setup/teardown
|
||||||
EXITSTATUS_TESTEXIT = 4
|
EXITSTATUS_TESTEXIT = 4
|
||||||
from py.__.test.dist.mypickle import ImmutablePickler
|
from _py.test.dist.mypickle import ImmutablePickler
|
||||||
ipickle = ImmutablePickler(uneven=0)
|
ipickle = ImmutablePickler(uneven=0)
|
||||||
ipickle.selfmemoize(item.config)
|
ipickle.selfmemoize(item.config)
|
||||||
# XXX workaround the issue that 2.6 cannot pickle
|
# XXX workaround the issue that 2.6 cannot pickle
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue