From 5791c06bf2d46adfd31cbc1048864ce4d38ecb21 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Sat, 3 Oct 2009 01:47:39 +0200 Subject: [PATCH] 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 --- {py/rest => _py}/__init__.py | 0 {py => _py}/_com.py | 4 +- {py => _py}/builtin/__init__.py | 0 {py => _py}/builtin/builtin24.py | 0 {py => _py}/builtin/builtin25.py | 0 {py => _py}/builtin/builtin31.py | 0 {py => _py}/cmdline/__init__.py | 0 {py => _py}/cmdline/pycleanup.py | 0 {py => _py}/cmdline/pyconvert_unittest.py | 0 {py => _py}/cmdline/pycountloc.py | 0 {py => _py}/cmdline/pylookup.py | 2 +- {py => _py}/cmdline/pyrest.py | 4 +- {py => _py}/cmdline/pysvnwcrevert.py | 0 {py => _py}/cmdline/pytest.py | 0 {py => _py}/cmdline/pywhich.py | 0 {py => _py}/code/__init__.py | 0 {py => _py}/code/_assertionnew.py | 2 +- {py => _py}/code/_assertionold.py | 2 +- {py => _py}/code/assertion.py | 4 +- {py => _py}/code/code.py | 6 +- {py => _py}/code/oldmagic.py | 0 {py => _py}/code/oldmagic2.py | 0 {py => _py}/code/source.py | 0 {py => _py}/compat/__init__.py | 0 {py => _py}/compat/dep_doctest.py | 0 {py => _py}/compat/dep_optparse.py | 0 {py => _py}/compat/dep_subprocess.py | 0 {py => _py}/compat/dep_textwrap.py | 0 {py => _py}/error.py | 0 {py => _py}/io/__init__.py | 0 {py => _py}/io/capture.py | 0 {py => _py}/io/terminalwriter.py | 0 {py => _py}/log/__init__.py | 0 {py => _py}/log/log.py | 0 {py => _py}/log/warning.py | 0 {py => _py}/path/__init__.py | 0 {py => _py}/path/cacheutil.py | 0 {py => _py}/path/common.py | 0 {py => _py}/path/gateway/__init__.py | 0 {py => _py}/path/gateway/channeltest.py | 0 {py => _py}/path/gateway/channeltest2.py | 0 {py => _py}/path/gateway/remotepath.py | 2 +- {py => _py}/path/local.py | 16 +- {py => _py}/path/svnurl.py | 6 +- {py => _py}/path/svnwc.py | 2 +- {py => _py}/process/__init__.py | 0 {py => _py}/process/cmdexec.py | 0 {py => _py}/process/forkedfunc.py | 0 {py => _py}/process/killproc.py | 0 {py/test/web => _py/rest}/__init__.py | 0 {py => _py}/rest/convert.py | 2 +- {py => _py}/rest/directive.py | 2 +- {py => _py}/rest/latex.py | 2 +- {py => _py}/rest/rest.sty.template | 0 {py => _py}/rest/resthtml.py | 2 +- {py => _py}/std.py | 0 {py => _py}/test/__init__.py | 0 {py => _py}/test/cmdline.py | 0 {py => _py}/test/collect.py | 2 +- {py => _py}/test/compat.py | 0 {py => _py}/test/config.py | 24 +- {py => _py}/test/conftesthandle.py | 0 {py => _py}/test/defaultconftest.py | 0 {py => _py}/test/dist/__init__.py | 0 {py => _py}/test/dist/dsession.py | 6 +- {py => _py}/test/dist/gwmanage.py | 0 {py => _py}/test/dist/mypickle.py | 0 {py => _py}/test/dist/nodemanage.py | 4 +- {py => _py}/test/dist/txnode.py | 6 +- {py => _py}/test/funcargs.py | 0 {py => _py}/test/looponfail/__init__.py | 0 {py => _py}/test/looponfail/remote.py | 10 +- {py => _py}/test/looponfail/util.py | 0 {py => _py}/test/outcome.py | 0 {py => _py}/test/parseopt.py | 0 {py => _py}/test/plugin/__init__.py | 0 {py => _py}/test/plugin/hookspec.py | 0 {py => _py}/test/plugin/pytest__pytest.py | 0 {py => _py}/test/plugin/pytest_assertion.py | 0 {py => _py}/test/plugin/pytest_capture.py | 0 {py => _py}/test/plugin/pytest_default.py | 6 +- {py => _py}/test/plugin/pytest_doctest.py | 2 +- {py => _py}/test/plugin/pytest_figleaf.py | 0 {py => _py}/test/plugin/pytest_helpconfig.py | 0 {py => _py}/test/plugin/pytest_hooklog.py | 0 {py => _py}/test/plugin/pytest_keyword.py | 0 {py => _py}/test/plugin/pytest_monkeypatch.py | 0 {py => _py}/test/plugin/pytest_nose.py | 0 {py => _py}/test/plugin/pytest_pastebin.py | 0 {py => _py}/test/plugin/pytest_pdb.py | 2 +- {py => _py}/test/plugin/pytest_pylint.py | 0 {py => _py}/test/plugin/pytest_pytester.py | 4 +- {py => _py}/test/plugin/pytest_recwarn.py | 0 {py => _py}/test/plugin/pytest_restdoc.py | 2 +- {py => _py}/test/plugin/pytest_resultlog.py | 0 {py => _py}/test/plugin/pytest_runner.py | 4 +- {py => _py}/test/plugin/pytest_terminal.py | 0 {py => _py}/test/plugin/pytest_tmpdir.py | 0 {py => _py}/test/plugin/pytest_unittest.py | 0 {py => _py}/test/plugin/pytest_xfail.py | 0 {py => _py}/test/pluginmanager.py | 12 +- {py => _py}/test/pycollect.py | 6 +- {py => _py}/test/session.py | 2 +- _py/test/web/__init__.py | 0 {py => _py}/test/web/exception.py | 0 {py => _py}/test/web/post_multipart.py | 0 {py => _py}/test/web/webcheck.py | 0 {py => _py}/thread/__init__.py | 0 {py => _py}/thread/io.py | 0 {py => _py}/thread/pool.py | 0 {py => _py}/xmlgen.py | 0 bin-for-dist/gensetup.py | 83 ++--- doc/changelog.txt | 5 +- py/__init__.py | 320 +++++++++--------- py/initpkg.py | 235 ------------- setup.py | 59 ++-- testing/cmdline/test_convert_unittest.py | 2 +- testing/code/test_assertion.py | 2 +- testing/code/test_code.py | 4 +- testing/code/test_excinfo.py | 6 +- testing/code/test_source.py | 10 +- testing/io_/test_capture.py | 2 +- testing/io_/test_terminalwriter.py | 2 +- testing/log/test_log.py | 2 +- testing/path/conftest.py | 2 +- testing/path/svntestbase.py | 2 +- testing/path/test_cacheutil.py | 2 +- testing/path/test_svnurl.py | 2 +- testing/path/test_svnwc.py | 4 +- testing/process/test_cmdexec.py | 2 +- testing/pytest/dist/test_dsession.py | 4 +- testing/pytest/dist/test_gwmanage.py | 4 +- testing/pytest/dist/test_mypickle.py | 18 +- testing/pytest/dist/test_nodemanage.py | 2 +- testing/pytest/dist/test_txnode.py | 2 +- testing/pytest/looponfail/test_remote.py | 2 +- testing/pytest/looponfail/test_util.py | 2 +- testing/pytest/plugin/conftest.py | 4 +- testing/pytest/plugin/test_pytest__pytest.py | 2 +- testing/pytest/plugin/test_pytest_capture.py | 2 +- testing/pytest/plugin/test_pytest_default.py | 2 +- testing/pytest/plugin/test_pytest_doctest.py | 4 +- testing/pytest/plugin/test_pytest_keyword.py | 2 +- .../pytest/plugin/test_pytest_monkeypatch.py | 2 +- testing/pytest/plugin/test_pytest_pytester.py | 2 +- testing/pytest/plugin/test_pytest_recwarn.py | 2 +- testing/pytest/plugin/test_pytest_restdoc.py | 6 +- .../pytest/plugin/test_pytest_resultlog.py | 4 +- testing/pytest/plugin/test_pytest_runner.py | 10 +- testing/pytest/plugin/test_pytest_terminal.py | 4 +- testing/pytest/plugin/test_pytest_tmpdir.py | 4 +- testing/pytest/test_collect.py | 2 +- testing/pytest/test_compat.py | 4 +- testing/pytest/test_config.py | 6 +- testing/pytest/test_conftesthandle.py | 2 +- testing/pytest/test_funcargs.py | 2 +- testing/pytest/test_outcome.py | 2 +- testing/pytest/test_parseopt.py | 2 +- testing/pytest/test_pickling.py | 8 +- testing/pytest/test_pluginmanager.py | 6 +- testing/pytest/test_pycollect.py | 2 +- testing/pytest/test_traceback.py | 2 +- testing/rest/test_convert.py | 2 +- testing/rest/test_directive.py | 4 +- testing/rest/test_htmlrest.py | 2 +- testing/rest/test_rst2pdf.py | 2 +- testing/root/test_com.py | 2 +- testing/root/test_initpkg.py | 184 ---------- testing/root/test_xmlgen.py | 2 +- testing/test_py_imports.py | 73 ++++ testing/thread/test_pool.py | 2 +- 171 files changed, 447 insertions(+), 844 deletions(-) rename {py/rest => _py}/__init__.py (100%) rename {py => _py}/_com.py (98%) rename {py => _py}/builtin/__init__.py (100%) rename {py => _py}/builtin/builtin24.py (100%) rename {py => _py}/builtin/builtin25.py (100%) rename {py => _py}/builtin/builtin31.py (100%) rename {py => _py}/cmdline/__init__.py (100%) rename {py => _py}/cmdline/pycleanup.py (100%) rename {py => _py}/cmdline/pyconvert_unittest.py (100%) rename {py => _py}/cmdline/pycountloc.py (100%) rename {py => _py}/cmdline/pylookup.py (97%) rename {py => _py}/cmdline/pyrest.py (94%) rename {py => _py}/cmdline/pysvnwcrevert.py (100%) rename {py => _py}/cmdline/pytest.py (100%) rename {py => _py}/cmdline/pywhich.py (100%) rename {py => _py}/code/__init__.py (100%) rename {py => _py}/code/_assertionnew.py (99%) rename {py => _py}/code/_assertionold.py (99%) rename {py => _py}/code/assertion.py (95%) rename {py => _py}/code/code.py (99%) rename {py => _py}/code/oldmagic.py (100%) rename {py => _py}/code/oldmagic2.py (100%) rename {py => _py}/code/source.py (100%) rename {py => _py}/compat/__init__.py (100%) rename {py => _py}/compat/dep_doctest.py (100%) rename {py => _py}/compat/dep_optparse.py (100%) rename {py => _py}/compat/dep_subprocess.py (100%) rename {py => _py}/compat/dep_textwrap.py (100%) rename {py => _py}/error.py (100%) rename {py => _py}/io/__init__.py (100%) rename {py => _py}/io/capture.py (100%) rename {py => _py}/io/terminalwriter.py (100%) rename {py => _py}/log/__init__.py (100%) rename {py => _py}/log/log.py (100%) rename {py => _py}/log/warning.py (100%) rename {py => _py}/path/__init__.py (100%) rename {py => _py}/path/cacheutil.py (100%) rename {py => _py}/path/common.py (100%) rename {py => _py}/path/gateway/__init__.py (100%) rename {py => _py}/path/gateway/channeltest.py (100%) rename {py => _py}/path/gateway/channeltest2.py (100%) rename {py => _py}/path/gateway/remotepath.py (97%) rename {py => _py}/path/local.py (98%) rename {py => _py}/path/svnurl.py (99%) rename {py => _py}/path/svnwc.py (99%) rename {py => _py}/process/__init__.py (100%) rename {py => _py}/process/cmdexec.py (100%) rename {py => _py}/process/forkedfunc.py (100%) rename {py => _py}/process/killproc.py (100%) rename {py/test/web => _py/rest}/__init__.py (100%) rename {py => _py}/rest/convert.py (99%) rename {py => _py}/rest/directive.py (98%) rename {py => _py}/rest/latex.py (99%) rename {py => _py}/rest/rest.sty.template (100%) rename {py => _py}/rest/resthtml.py (98%) rename {py => _py}/std.py (100%) rename {py => _py}/test/__init__.py (100%) rename {py => _py}/test/cmdline.py (100%) rename {py => _py}/test/collect.py (99%) rename {py => _py}/test/compat.py (100%) rename {py => _py}/test/config.py (95%) rename {py => _py}/test/conftesthandle.py (100%) rename {py => _py}/test/defaultconftest.py (100%) rename {py => _py}/test/dist/__init__.py (100%) rename {py => _py}/test/dist/dsession.py (98%) rename {py => _py}/test/dist/gwmanage.py (100%) rename {py => _py}/test/dist/mypickle.py (100%) rename {py => _py}/test/dist/nodemanage.py (96%) rename {py => _py}/test/dist/txnode.py (97%) rename {py => _py}/test/funcargs.py (100%) rename {py => _py}/test/looponfail/__init__.py (100%) rename {py => _py}/test/looponfail/remote.py (95%) rename {py => _py}/test/looponfail/util.py (100%) rename {py => _py}/test/outcome.py (100%) rename {py => _py}/test/parseopt.py (100%) rename {py => _py}/test/plugin/__init__.py (100%) rename {py => _py}/test/plugin/hookspec.py (100%) rename {py => _py}/test/plugin/pytest__pytest.py (100%) rename {py => _py}/test/plugin/pytest_assertion.py (100%) rename {py => _py}/test/plugin/pytest_capture.py (100%) rename {py => _py}/test/plugin/pytest_default.py (96%) rename {py => _py}/test/plugin/pytest_doctest.py (98%) rename {py => _py}/test/plugin/pytest_figleaf.py (100%) rename {py => _py}/test/plugin/pytest_helpconfig.py (100%) rename {py => _py}/test/plugin/pytest_hooklog.py (100%) rename {py => _py}/test/plugin/pytest_keyword.py (100%) rename {py => _py}/test/plugin/pytest_monkeypatch.py (100%) rename {py => _py}/test/plugin/pytest_nose.py (100%) rename {py => _py}/test/plugin/pytest_pastebin.py (100%) rename {py => _py}/test/plugin/pytest_pdb.py (99%) rename {py => _py}/test/plugin/pytest_pylint.py (100%) rename {py => _py}/test/plugin/pytest_pytester.py (99%) rename {py => _py}/test/plugin/pytest_recwarn.py (100%) rename {py => _py}/test/plugin/pytest_restdoc.py (99%) rename {py => _py}/test/plugin/pytest_resultlog.py (100%) rename {py => _py}/test/plugin/pytest_runner.py (99%) rename {py => _py}/test/plugin/pytest_terminal.py (100%) rename {py => _py}/test/plugin/pytest_tmpdir.py (100%) rename {py => _py}/test/plugin/pytest_unittest.py (100%) rename {py => _py}/test/plugin/pytest_xfail.py (100%) rename {py => _py}/test/pluginmanager.py (96%) rename {py => _py}/test/pycollect.py (98%) rename {py => _py}/test/session.py (99%) create mode 100644 _py/test/web/__init__.py rename {py => _py}/test/web/exception.py (100%) rename {py => _py}/test/web/post_multipart.py (100%) rename {py => _py}/test/web/webcheck.py (100%) rename {py => _py}/thread/__init__.py (100%) rename {py => _py}/thread/io.py (100%) rename {py => _py}/thread/pool.py (100%) rename {py => _py}/xmlgen.py (100%) delete mode 100644 py/initpkg.py delete mode 100644 testing/root/test_initpkg.py create mode 100644 testing/test_py_imports.py diff --git a/py/rest/__init__.py b/_py/__init__.py similarity index 100% rename from py/rest/__init__.py rename to _py/__init__.py diff --git a/py/_com.py b/_py/_com.py similarity index 98% rename from py/_com.py rename to _py/_com.py index d157e2168..118e38663 100644 --- a/py/_com.py +++ b/_py/_com.py @@ -4,7 +4,9 @@ py lib plugins and plugin call management import py import inspect - + +__all__ = ['Registry', 'MultiCall', 'comregistry', 'HookRelay'] + class MultiCall: """ execute a call into multiple python functions/methods. """ diff --git a/py/builtin/__init__.py b/_py/builtin/__init__.py similarity index 100% rename from py/builtin/__init__.py rename to _py/builtin/__init__.py diff --git a/py/builtin/builtin24.py b/_py/builtin/builtin24.py similarity index 100% rename from py/builtin/builtin24.py rename to _py/builtin/builtin24.py diff --git a/py/builtin/builtin25.py b/_py/builtin/builtin25.py similarity index 100% rename from py/builtin/builtin25.py rename to _py/builtin/builtin25.py diff --git a/py/builtin/builtin31.py b/_py/builtin/builtin31.py similarity index 100% rename from py/builtin/builtin31.py rename to _py/builtin/builtin31.py diff --git a/py/cmdline/__init__.py b/_py/cmdline/__init__.py similarity index 100% rename from py/cmdline/__init__.py rename to _py/cmdline/__init__.py diff --git a/py/cmdline/pycleanup.py b/_py/cmdline/pycleanup.py similarity index 100% rename from py/cmdline/pycleanup.py rename to _py/cmdline/pycleanup.py diff --git a/py/cmdline/pyconvert_unittest.py b/_py/cmdline/pyconvert_unittest.py similarity index 100% rename from py/cmdline/pyconvert_unittest.py rename to _py/cmdline/pyconvert_unittest.py diff --git a/py/cmdline/pycountloc.py b/_py/cmdline/pycountloc.py similarity index 100% rename from py/cmdline/pycountloc.py rename to _py/cmdline/pycountloc.py diff --git a/py/cmdline/pylookup.py b/_py/cmdline/pylookup.py similarity index 97% rename from py/cmdline/pylookup.py rename to _py/cmdline/pylookup.py index e9e21346a..e087609ba 100755 --- a/py/cmdline/pylookup.py +++ b/_py/cmdline/pylookup.py @@ -9,7 +9,7 @@ prepended.""" import sys, os import py -from py.__.io.terminalwriter import ansi_print, terminal_width +from _py.io.terminalwriter import ansi_print, terminal_width import re def rec(p): diff --git a/py/cmdline/pyrest.py b/_py/cmdline/pyrest.py similarity index 94% rename from py/cmdline/pyrest.py rename to _py/cmdline/pyrest.py index b9b8a99ab..490aa9d02 100755 --- a/py/cmdline/pyrest.py +++ b/_py/cmdline/pyrest.py @@ -35,8 +35,8 @@ parser.add_option("--debug", action="store_true", dest="debug", def main(): try: - from py.__.rest import directive, resthtml - from py.__.rest.latex import process_rest_file, process_configfile + from _py.rest import directive, resthtml + from _py.rest.latex import process_rest_file, process_configfile except ImportError: e = sys.exc_info()[1] print(str(e)) diff --git a/py/cmdline/pysvnwcrevert.py b/_py/cmdline/pysvnwcrevert.py similarity index 100% rename from py/cmdline/pysvnwcrevert.py rename to _py/cmdline/pysvnwcrevert.py diff --git a/py/cmdline/pytest.py b/_py/cmdline/pytest.py similarity index 100% rename from py/cmdline/pytest.py rename to _py/cmdline/pytest.py diff --git a/py/cmdline/pywhich.py b/_py/cmdline/pywhich.py similarity index 100% rename from py/cmdline/pywhich.py rename to _py/cmdline/pywhich.py diff --git a/py/code/__init__.py b/_py/code/__init__.py similarity index 100% rename from py/code/__init__.py rename to _py/code/__init__.py diff --git a/py/code/_assertionnew.py b/_py/code/_assertionnew.py similarity index 99% rename from py/code/_assertionnew.py rename to _py/code/_assertionnew.py index d112321ca..606dfa75c 100644 --- a/py/code/_assertionnew.py +++ b/_py/code/_assertionnew.py @@ -7,7 +7,7 @@ import sys import ast import py -from py.__.code.assertion import _format_explanation, BuiltinAssertionError +from _py.code.assertion import _format_explanation, BuiltinAssertionError class Failure(Exception): diff --git a/py/code/_assertionold.py b/_py/code/_assertionold.py similarity index 99% rename from py/code/_assertionold.py rename to _py/code/_assertionold.py index 947fea357..448fdef3e 100644 --- a/py/code/_assertionold.py +++ b/_py/code/_assertionold.py @@ -1,7 +1,7 @@ import py import sys, inspect 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) diff --git a/py/code/assertion.py b/_py/code/assertion.py similarity index 95% rename from py/code/assertion.py rename to _py/code/assertion.py index f3c93c3ca..4d53d59e4 100644 --- a/py/code/assertion.py +++ b/_py/code/assertion.py @@ -38,9 +38,9 @@ def _format_explanation(explanation): if sys.version_info >= (2, 6): - from py.__.code._assertionnew import interpret + from _py.code._assertionnew import interpret else: - from py.__.code._assertionold import interpret + from _py.code._assertionold import interpret class AssertionError(BuiltinAssertionError): diff --git a/py/code/code.py b/_py/code/code.py similarity index 99% rename from py/code/code.py rename to _py/code/code.py index 64962a436..86582909a 100644 --- a/py/code/code.py +++ b/_py/code/code.py @@ -84,7 +84,7 @@ class Code(object): def fullsource(self): """ 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) return full fullsource = property(fullsource, None, None, @@ -196,7 +196,7 @@ class TracebackEntry(object): """Reinterpret the failing statement and returns a detailed information about what operations are performed.""" if self.exprinfo is None: - from py.__.code import assertion + from _py.code import assertion source = str(self.statement).strip() x = assertion.interpret(source, self.frame, should_fail=True) if not isinstance(x, str): @@ -738,7 +738,7 @@ oldbuiltins = {} def patch_builtins(assertion=True, compile=True): """ put compile and AssertionError builtins to Python's builtins. """ if assertion: - from py.__.code import assertion + from _py.code import assertion l = oldbuiltins.setdefault('AssertionError', []) l.append(py.builtin.builtins.AssertionError) py.builtin.builtins.AssertionError = assertion.AssertionError diff --git a/py/code/oldmagic.py b/_py/code/oldmagic.py similarity index 100% rename from py/code/oldmagic.py rename to _py/code/oldmagic.py diff --git a/py/code/oldmagic2.py b/_py/code/oldmagic2.py similarity index 100% rename from py/code/oldmagic2.py rename to _py/code/oldmagic2.py diff --git a/py/code/source.py b/_py/code/source.py similarity index 100% rename from py/code/source.py rename to _py/code/source.py diff --git a/py/compat/__init__.py b/_py/compat/__init__.py similarity index 100% rename from py/compat/__init__.py rename to _py/compat/__init__.py diff --git a/py/compat/dep_doctest.py b/_py/compat/dep_doctest.py similarity index 100% rename from py/compat/dep_doctest.py rename to _py/compat/dep_doctest.py diff --git a/py/compat/dep_optparse.py b/_py/compat/dep_optparse.py similarity index 100% rename from py/compat/dep_optparse.py rename to _py/compat/dep_optparse.py diff --git a/py/compat/dep_subprocess.py b/_py/compat/dep_subprocess.py similarity index 100% rename from py/compat/dep_subprocess.py rename to _py/compat/dep_subprocess.py diff --git a/py/compat/dep_textwrap.py b/_py/compat/dep_textwrap.py similarity index 100% rename from py/compat/dep_textwrap.py rename to _py/compat/dep_textwrap.py diff --git a/py/error.py b/_py/error.py similarity index 100% rename from py/error.py rename to _py/error.py diff --git a/py/io/__init__.py b/_py/io/__init__.py similarity index 100% rename from py/io/__init__.py rename to _py/io/__init__.py diff --git a/py/io/capture.py b/_py/io/capture.py similarity index 100% rename from py/io/capture.py rename to _py/io/capture.py diff --git a/py/io/terminalwriter.py b/_py/io/terminalwriter.py similarity index 100% rename from py/io/terminalwriter.py rename to _py/io/terminalwriter.py diff --git a/py/log/__init__.py b/_py/log/__init__.py similarity index 100% rename from py/log/__init__.py rename to _py/log/__init__.py diff --git a/py/log/log.py b/_py/log/log.py similarity index 100% rename from py/log/log.py rename to _py/log/log.py diff --git a/py/log/warning.py b/_py/log/warning.py similarity index 100% rename from py/log/warning.py rename to _py/log/warning.py diff --git a/py/path/__init__.py b/_py/path/__init__.py similarity index 100% rename from py/path/__init__.py rename to _py/path/__init__.py diff --git a/py/path/cacheutil.py b/_py/path/cacheutil.py similarity index 100% rename from py/path/cacheutil.py rename to _py/path/cacheutil.py diff --git a/py/path/common.py b/_py/path/common.py similarity index 100% rename from py/path/common.py rename to _py/path/common.py diff --git a/py/path/gateway/__init__.py b/_py/path/gateway/__init__.py similarity index 100% rename from py/path/gateway/__init__.py rename to _py/path/gateway/__init__.py diff --git a/py/path/gateway/channeltest.py b/_py/path/gateway/channeltest.py similarity index 100% rename from py/path/gateway/channeltest.py rename to _py/path/gateway/channeltest.py diff --git a/py/path/gateway/channeltest2.py b/_py/path/gateway/channeltest2.py similarity index 100% rename from py/path/gateway/channeltest2.py rename to _py/path/gateway/channeltest2.py diff --git a/py/path/gateway/remotepath.py b/_py/path/gateway/remotepath.py similarity index 97% rename from py/path/gateway/remotepath.py rename to _py/path/gateway/remotepath.py index e032a766f..17cc1857e 100644 --- a/py/path/gateway/remotepath.py +++ b/_py/path/gateway/remotepath.py @@ -1,5 +1,5 @@ import py, itertools -from py.__.path import common +from _py.path import common COUNTER = itertools.count() diff --git a/py/path/local.py b/_py/path/local.py similarity index 98% rename from py/path/local.py rename to _py/path/local.py index 7adab5030..12df59f69 100644 --- a/py/path/local.py +++ b/_py/path/local.py @@ -1,10 +1,9 @@ """ local path implementation. """ -from __future__ import generators import sys, os, stat, re, atexit import py -from py.__.path import common +from _py.path import common iswin32 = sys.platform == "win32" @@ -508,16 +507,9 @@ class LocalPath(FSBase): if ensuresyspath: self._prependsyspath(pkgpath.dirpath()) pkg = __import__(pkgpath.basename, None, None, []) - - if hasattr(pkg, '__pkg__'): - modname = pkg.__pkg__.getimportname(self) - 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) + names = self.new(ext='').relto(pkgpath.dirpath()) + names = names.split(self.sep) + modname = ".".join(names) else: # no package scope, still make it possible if ensuresyspath: diff --git a/py/path/svnurl.py b/_py/path/svnurl.py similarity index 99% rename from py/path/svnurl.py rename to _py/path/svnurl.py index 2f31e318f..353b6389c 100644 --- a/py/path/svnurl.py +++ b/_py/path/svnurl.py @@ -7,9 +7,9 @@ but might also interact well with earlier versions. import os, sys, time, re import py from py import path, process -from py.__.path import common -from py.__.path import svnwc as svncommon -from py.__.path.cacheutil import BuildcostAccessCache, AgingCache +from _py.path import common +from _py.path import svnwc as svncommon +from _py.path.cacheutil import BuildcostAccessCache, AgingCache DEBUG=False diff --git a/py/path/svnwc.py b/_py/path/svnwc.py similarity index 99% rename from py/path/svnwc.py rename to _py/path/svnwc.py index ee78fdced..5575ee06c 100644 --- a/py/path/svnwc.py +++ b/_py/path/svnwc.py @@ -8,7 +8,7 @@ svn-Command based Implementation of a Subversion WorkingCopy Path. import os, sys, time, re, calendar import py import subprocess -from py.__.path import common +from _py.path import common #----------------------------------------------------------- # Caching latest repository revision and repo-paths diff --git a/py/process/__init__.py b/_py/process/__init__.py similarity index 100% rename from py/process/__init__.py rename to _py/process/__init__.py diff --git a/py/process/cmdexec.py b/_py/process/cmdexec.py similarity index 100% rename from py/process/cmdexec.py rename to _py/process/cmdexec.py diff --git a/py/process/forkedfunc.py b/_py/process/forkedfunc.py similarity index 100% rename from py/process/forkedfunc.py rename to _py/process/forkedfunc.py diff --git a/py/process/killproc.py b/_py/process/killproc.py similarity index 100% rename from py/process/killproc.py rename to _py/process/killproc.py diff --git a/py/test/web/__init__.py b/_py/rest/__init__.py similarity index 100% rename from py/test/web/__init__.py rename to _py/rest/__init__.py diff --git a/py/rest/convert.py b/_py/rest/convert.py similarity index 99% rename from py/rest/convert.py rename to _py/rest/convert.py index 523cac7df..02ffc8ab5 100644 --- a/py/rest/convert.py +++ b/_py/rest/convert.py @@ -1,6 +1,6 @@ import py -from py.__.process.cmdexec import ExecutionFailed +from _py.process.cmdexec import ExecutionFailed # utility functions to convert between various formats format_to_dotargument = {"png": "png", diff --git a/py/rest/directive.py b/_py/rest/directive.py similarity index 98% rename from py/rest/directive.py rename to _py/rest/directive.py index 499d0313f..e80cf5e5b 100644 --- a/py/rest/directive.py +++ b/_py/rest/directive.py @@ -1,7 +1,7 @@ # XXX this file is messy since it tries to deal with several docutils versions import py -from py.__.rest.convert import convert_dot, latexformula2png +from _py.rest.convert import convert_dot, latexformula2png import sys import docutils diff --git a/py/rest/latex.py b/_py/rest/latex.py similarity index 99% rename from py/rest/latex.py rename to _py/rest/latex.py index 67816f128..e8435ec69 100644 --- a/py/rest/latex.py +++ b/_py/rest/latex.py @@ -1,6 +1,6 @@ import py -from py.__.process.cmdexec import ExecutionFailed +from _py.process.cmdexec import ExecutionFailed font_to_package = {"times": "times", "helvetica": "times", "new century schoolbock": "newcent", "avant garde": "newcent", diff --git a/py/rest/rest.sty.template b/_py/rest/rest.sty.template similarity index 100% rename from py/rest/rest.sty.template rename to _py/rest/rest.sty.template diff --git a/py/rest/resthtml.py b/_py/rest/resthtml.py similarity index 98% rename from py/rest/resthtml.py rename to _py/rest/resthtml.py index edba3a4a5..b6b68a0a6 100644 --- a/py/rest/resthtml.py +++ b/_py/rest/resthtml.py @@ -10,7 +10,7 @@ else: pass 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. source a ReST-string sourcepath where to look for includes (basically) diff --git a/py/std.py b/_py/std.py similarity index 100% rename from py/std.py rename to _py/std.py diff --git a/py/test/__init__.py b/_py/test/__init__.py similarity index 100% rename from py/test/__init__.py rename to _py/test/__init__.py diff --git a/py/test/cmdline.py b/_py/test/cmdline.py similarity index 100% rename from py/test/cmdline.py rename to _py/test/cmdline.py diff --git a/py/test/collect.py b/_py/test/collect.py similarity index 99% rename from py/test/collect.py rename to _py/test/collect.py index a3d6ec9e9..cd96e6714 100644 --- a/py/test/collect.py +++ b/_py/test/collect.py @@ -4,7 +4,7 @@ Collectors and test Items form a tree that is usually built iteratively. """ import py -pydir = py.path.local(py.__file__).dirpath() +pydir = py.path.local(py._py.__file__).dirpath() def configproperty(name): def fget(self): diff --git a/py/test/compat.py b/_py/test/compat.py similarity index 100% rename from py/test/compat.py rename to _py/test/compat.py diff --git a/py/test/config.py b/_py/test/config.py similarity index 95% rename from py/test/config.py rename to _py/test/config.py index ed2b88cb3..e5b2dd2be 100644 --- a/py/test/config.py +++ b/_py/test/config.py @@ -1,7 +1,7 @@ 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): """ return temporary directory path with @@ -221,7 +221,7 @@ class Config(object): """ return an initialized session object. """ cls = self._sessionclass if cls is None: - from py.__.test.session import Session + from _py.test.session import Session cls = Session session = cls(self) self.trace("instantiated session %r" % session) @@ -256,24 +256,22 @@ class Config(object): return [execnet.XSpec(x) for x in xspeclist] def getrsyncdirs(self): - config = self + config = self roots = config.option.rsyncdir conftestroots = config.getconftest_pathlist("rsyncdirs") if 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] for root in roots: if not root.check(): raise config.Error("rsyncdir doesn't exist: %r" %(root,)) - if pydir is not None and root.basename == "py": - if root != pydir: - raise config.Error("root %r conflicts with imported %r" %(root, pydir)) - pydir = None - if pydir is not None: - roots.append(pydir) - return roots - + if pydirs is not None and root.basename in ("py", "_py"): + pydirs.remove(root) # otherwise it's a conflict + roots.extend(pydirs) + return roots + # # helpers # diff --git a/py/test/conftesthandle.py b/_py/test/conftesthandle.py similarity index 100% rename from py/test/conftesthandle.py rename to _py/test/conftesthandle.py diff --git a/py/test/defaultconftest.py b/_py/test/defaultconftest.py similarity index 100% rename from py/test/defaultconftest.py rename to _py/test/defaultconftest.py diff --git a/py/test/dist/__init__.py b/_py/test/dist/__init__.py similarity index 100% rename from py/test/dist/__init__.py rename to _py/test/dist/__init__.py diff --git a/py/test/dist/dsession.py b/_py/test/dist/dsession.py similarity index 98% rename from py/test/dist/dsession.py rename to _py/test/dist/dsession.py index b593c05ae..b2350509d 100644 --- a/py/test/dist/dsession.py +++ b/_py/test/dist/dsession.py @@ -5,9 +5,9 @@ """ import py -from py.__.test.session import Session -from py.__.test import outcome -from py.__.test.dist.nodemanage import NodeManager +from _py.test.session import Session +from _py.test import outcome +from _py.test.dist.nodemanage import NodeManager queue = py.builtin._tryimport('queue', 'Queue') debug_file = None # open('/tmp/loop.log', 'w') diff --git a/py/test/dist/gwmanage.py b/_py/test/dist/gwmanage.py similarity index 100% rename from py/test/dist/gwmanage.py rename to _py/test/dist/gwmanage.py diff --git a/py/test/dist/mypickle.py b/_py/test/dist/mypickle.py similarity index 100% rename from py/test/dist/mypickle.py rename to _py/test/dist/mypickle.py diff --git a/py/test/dist/nodemanage.py b/_py/test/dist/nodemanage.py similarity index 96% rename from py/test/dist/nodemanage.py rename to _py/test/dist/nodemanage.py index 5ba6525e7..ed7b8b0a2 100644 --- a/py/test/dist/nodemanage.py +++ b/_py/test/dist/nodemanage.py @@ -1,7 +1,7 @@ import py import sys, os -from py.__.test.dist.txnode import TXNode -from py.__.test.dist.gwmanage import GatewayManager +from _py.test.dist.txnode import TXNode +from _py.test.dist.gwmanage import GatewayManager class NodeManager(object): diff --git a/py/test/dist/txnode.py b/_py/test/dist/txnode.py similarity index 97% rename from py/test/dist/txnode.py rename to _py/test/dist/txnode.py index 3c6f1b90f..8406afef0 100644 --- a/py/test/dist/txnode.py +++ b/_py/test/dist/txnode.py @@ -2,7 +2,7 @@ Manage setup, running and local representation of remote nodes/processes. """ import py -from py.__.test.dist.mypickle import PickleChannel +from _py.test.dist.mypickle import PickleChannel class TXNode(object): """ Represents a Test Execution environment in the controlling process. @@ -84,8 +84,8 @@ def install_slave(gateway, config): channel = gateway.remote_exec(source=""" import os, sys sys.path.insert(0, os.getcwd()) - from py.__.test.dist.mypickle import PickleChannel - from py.__.test.dist.txnode import SlaveNode + from _py.test.dist.mypickle import PickleChannel + from _py.test.dist.txnode import SlaveNode channel = PickleChannel(channel) slavenode = SlaveNode(channel) slavenode.run() diff --git a/py/test/funcargs.py b/_py/test/funcargs.py similarity index 100% rename from py/test/funcargs.py rename to _py/test/funcargs.py diff --git a/py/test/looponfail/__init__.py b/_py/test/looponfail/__init__.py similarity index 100% rename from py/test/looponfail/__init__.py rename to _py/test/looponfail/__init__.py diff --git a/py/test/looponfail/remote.py b/_py/test/looponfail/remote.py similarity index 95% rename from py/test/looponfail/remote.py rename to _py/test/looponfail/remote.py index dee445281..7374e334c 100644 --- a/py/test/looponfail/remote.py +++ b/_py/test/looponfail/remote.py @@ -10,9 +10,9 @@ import py import sys import execnet -from py.__.test.session import Session -from py.__.test.dist.mypickle import PickleChannel -from py.__.test.looponfail import util +from _py.test.session import Session +from _py.test.dist.mypickle import PickleChannel +from _py.test.looponfail import util class LooponfailingSession(Session): def __init__(self, config): @@ -68,8 +68,8 @@ class RemoteControl(object): finally: old.chdir() channel = self.gateway.remote_exec(source=""" - from py.__.test.dist.mypickle import PickleChannel - from py.__.test.looponfail.remote import slave_runsession + from _py.test.dist.mypickle import PickleChannel + from _py.test.looponfail.remote import slave_runsession outchannel = channel.gateway.newchannel() channel.send(outchannel) channel = PickleChannel(channel) diff --git a/py/test/looponfail/util.py b/_py/test/looponfail/util.py similarity index 100% rename from py/test/looponfail/util.py rename to _py/test/looponfail/util.py diff --git a/py/test/outcome.py b/_py/test/outcome.py similarity index 100% rename from py/test/outcome.py rename to _py/test/outcome.py diff --git a/py/test/parseopt.py b/_py/test/parseopt.py similarity index 100% rename from py/test/parseopt.py rename to _py/test/parseopt.py diff --git a/py/test/plugin/__init__.py b/_py/test/plugin/__init__.py similarity index 100% rename from py/test/plugin/__init__.py rename to _py/test/plugin/__init__.py diff --git a/py/test/plugin/hookspec.py b/_py/test/plugin/hookspec.py similarity index 100% rename from py/test/plugin/hookspec.py rename to _py/test/plugin/hookspec.py diff --git a/py/test/plugin/pytest__pytest.py b/_py/test/plugin/pytest__pytest.py similarity index 100% rename from py/test/plugin/pytest__pytest.py rename to _py/test/plugin/pytest__pytest.py diff --git a/py/test/plugin/pytest_assertion.py b/_py/test/plugin/pytest_assertion.py similarity index 100% rename from py/test/plugin/pytest_assertion.py rename to _py/test/plugin/pytest_assertion.py diff --git a/py/test/plugin/pytest_capture.py b/_py/test/plugin/pytest_capture.py similarity index 100% rename from py/test/plugin/pytest_capture.py rename to _py/test/plugin/pytest_capture.py diff --git a/py/test/plugin/pytest_default.py b/_py/test/plugin/pytest_default.py similarity index 96% rename from py/test/plugin/pytest_default.py rename to _py/test/plugin/pytest_default.py index 543f11f14..028e49c4c 100644 --- a/py/test/plugin/pytest_default.py +++ b/_py/test/plugin/pytest_default.py @@ -120,12 +120,12 @@ def fixoptions(config): def setsession(config): val = config.getvalue if val("collectonly"): - from py.__.test.session import Session + from _py.test.session import Session config.setsessionclass(Session) elif execnet: if val("looponfail"): - from py.__.test.looponfail.remote import LooponfailingSession + from _py.test.looponfail.remote import LooponfailingSession config.setsessionclass(LooponfailingSession) elif val("dist") != "no": - from py.__.test.dist.dsession import DSession + from _py.test.dist.dsession import DSession config.setsessionclass(DSession) diff --git a/py/test/plugin/pytest_doctest.py b/_py/test/plugin/pytest_doctest.py similarity index 98% rename from py/test/plugin/pytest_doctest.py rename to _py/test/plugin/pytest_doctest.py index e87facf40..eb20afe09 100644 --- a/py/test/plugin/pytest_doctest.py +++ b/_py/test/plugin/pytest_doctest.py @@ -14,7 +14,7 @@ as well. """ import py -from py.__.code.code import TerminalRepr, ReprFileLocation +from _py.code.code import TerminalRepr, ReprFileLocation import doctest def pytest_addoption(parser): diff --git a/py/test/plugin/pytest_figleaf.py b/_py/test/plugin/pytest_figleaf.py similarity index 100% rename from py/test/plugin/pytest_figleaf.py rename to _py/test/plugin/pytest_figleaf.py diff --git a/py/test/plugin/pytest_helpconfig.py b/_py/test/plugin/pytest_helpconfig.py similarity index 100% rename from py/test/plugin/pytest_helpconfig.py rename to _py/test/plugin/pytest_helpconfig.py diff --git a/py/test/plugin/pytest_hooklog.py b/_py/test/plugin/pytest_hooklog.py similarity index 100% rename from py/test/plugin/pytest_hooklog.py rename to _py/test/plugin/pytest_hooklog.py diff --git a/py/test/plugin/pytest_keyword.py b/_py/test/plugin/pytest_keyword.py similarity index 100% rename from py/test/plugin/pytest_keyword.py rename to _py/test/plugin/pytest_keyword.py diff --git a/py/test/plugin/pytest_monkeypatch.py b/_py/test/plugin/pytest_monkeypatch.py similarity index 100% rename from py/test/plugin/pytest_monkeypatch.py rename to _py/test/plugin/pytest_monkeypatch.py diff --git a/py/test/plugin/pytest_nose.py b/_py/test/plugin/pytest_nose.py similarity index 100% rename from py/test/plugin/pytest_nose.py rename to _py/test/plugin/pytest_nose.py diff --git a/py/test/plugin/pytest_pastebin.py b/_py/test/plugin/pytest_pastebin.py similarity index 100% rename from py/test/plugin/pytest_pastebin.py rename to _py/test/plugin/pytest_pastebin.py diff --git a/py/test/plugin/pytest_pdb.py b/_py/test/plugin/pytest_pdb.py similarity index 99% rename from py/test/plugin/pytest_pdb.py rename to _py/test/plugin/pytest_pdb.py index 8925c5cc8..301b56e93 100644 --- a/py/test/plugin/pytest_pdb.py +++ b/_py/test/plugin/pytest_pdb.py @@ -3,7 +3,7 @@ interactive debugging with the Python Debugger. """ import py import pdb, sys, linecache -from py.__.test.outcome import Skipped +from _py.test.outcome import Skipped try: import execnet except ImportError: diff --git a/py/test/plugin/pytest_pylint.py b/_py/test/plugin/pytest_pylint.py similarity index 100% rename from py/test/plugin/pytest_pylint.py rename to _py/test/plugin/pytest_pylint.py diff --git a/py/test/plugin/pytest_pytester.py b/_py/test/plugin/pytest_pytester.py similarity index 99% rename from py/test/plugin/pytest_pytester.py rename to _py/test/plugin/pytest_pytester.py index 3f1e33eee..5bb473209 100644 --- a/py/test/plugin/pytest_pytester.py +++ b/_py/test/plugin/pytest_pytester.py @@ -5,8 +5,8 @@ funcargs and support code for testing py.test's own functionality. import py import sys, os import inspect -from py.__.test.config import Config as pytestConfig -from py.__.test.plugin import hookspec +from _py.test.config import Config as pytestConfig +from _py.test.plugin import hookspec from py.builtin import print_ pytest_plugins = '_pytest' diff --git a/py/test/plugin/pytest_recwarn.py b/_py/test/plugin/pytest_recwarn.py similarity index 100% rename from py/test/plugin/pytest_recwarn.py rename to _py/test/plugin/pytest_recwarn.py diff --git a/py/test/plugin/pytest_restdoc.py b/_py/test/plugin/pytest_restdoc.py similarity index 99% rename from py/test/plugin/pytest_restdoc.py rename to _py/test/plugin/pytest_restdoc.py index 7dacab5e2..a26d6e3a5 100644 --- a/py/test/plugin/pytest_restdoc.py +++ b/_py/test/plugin/pytest_restdoc.py @@ -87,7 +87,7 @@ class ReSTSyntaxTest(py.test.collect.Item): py.test.fail("docutils processing failed, see captured stderr") def register_linkrole(self): - from py.__.rest import directive + from _py.rest import directive directive.register_linkrole('api', self.resolve_linkrole) directive.register_linkrole('source', self.resolve_linkrole) diff --git a/py/test/plugin/pytest_resultlog.py b/_py/test/plugin/pytest_resultlog.py similarity index 100% rename from py/test/plugin/pytest_resultlog.py rename to _py/test/plugin/pytest_resultlog.py diff --git a/py/test/plugin/pytest_runner.py b/_py/test/plugin/pytest_runner.py similarity index 99% rename from py/test/plugin/pytest_runner.py rename to _py/test/plugin/pytest_runner.py index 594a280d6..b425dde7f 100644 --- a/py/test/plugin/pytest_runner.py +++ b/_py/test/plugin/pytest_runner.py @@ -3,7 +3,7 @@ collect and run test items and create reports. """ import py -from py.__.test.outcome import Skipped +from _py.test.outcome import Skipped # # pytest plugin hooks @@ -118,7 +118,7 @@ def forked_run_report(item): # for now, we run setup/teardown in the subprocess # XXX optionally allow sharing of setup/teardown EXITSTATUS_TESTEXIT = 4 - from py.__.test.dist.mypickle import ImmutablePickler + from _py.test.dist.mypickle import ImmutablePickler ipickle = ImmutablePickler(uneven=0) ipickle.selfmemoize(item.config) # XXX workaround the issue that 2.6 cannot pickle diff --git a/py/test/plugin/pytest_terminal.py b/_py/test/plugin/pytest_terminal.py similarity index 100% rename from py/test/plugin/pytest_terminal.py rename to _py/test/plugin/pytest_terminal.py diff --git a/py/test/plugin/pytest_tmpdir.py b/_py/test/plugin/pytest_tmpdir.py similarity index 100% rename from py/test/plugin/pytest_tmpdir.py rename to _py/test/plugin/pytest_tmpdir.py diff --git a/py/test/plugin/pytest_unittest.py b/_py/test/plugin/pytest_unittest.py similarity index 100% rename from py/test/plugin/pytest_unittest.py rename to _py/test/plugin/pytest_unittest.py diff --git a/py/test/plugin/pytest_xfail.py b/_py/test/plugin/pytest_xfail.py similarity index 100% rename from py/test/plugin/pytest_xfail.py rename to _py/test/plugin/pytest_xfail.py diff --git a/py/test/pluginmanager.py b/_py/test/pluginmanager.py similarity index 96% rename from py/test/pluginmanager.py rename to _py/test/pluginmanager.py index 453345830..8e122ca97 100644 --- a/py/test/pluginmanager.py +++ b/_py/test/pluginmanager.py @@ -2,8 +2,8 @@ managing loading and interacting with pytest plugins. """ import py -from py.__.test.plugin import hookspec -from py.__.test.outcome import Skipped +from _py.test.plugin import hookspec +from _py.test.outcome import Skipped def check_old_use(mod, modname): clsname = modname[len('pytest_'):].capitalize() + "Plugin" @@ -223,7 +223,7 @@ def importplugin(importspec): if str(e).find(importspec) == -1: raise try: - return __import__("py.__.test.plugin.%s" %(importspec), None, None, '__doc__') + return __import__("_py.test.plugin.%s" %(importspec), None, None, '__doc__') except ImportError: e = py.std.sys.exc_info()[1] if str(e).find(importspec) == -1: @@ -258,8 +258,8 @@ def formatdef(func): ) if __name__ == "__main__": - import py.__.test.plugin - basedir = py.path.local(py.__.test.plugin.__file__).dirpath() + import _py.test.plugin + basedir = py.path.local(_py.test.plugin.__file__).dirpath() name2text = {} for p in basedir.listdir("pytest_*"): if p.ext == ".py" or ( @@ -269,7 +269,7 @@ if __name__ == "__main__": continue try: plugin = importplugin(impname) - except (ImportError, py.__.test.outcome.Skipped): + except (ImportError, _py.test.outcome.Skipped): name2text[impname] = "IMPORT ERROR" else: doc = plugin.__doc__ or "" diff --git a/py/test/pycollect.py b/_py/test/pycollect.py similarity index 98% rename from py/test/pycollect.py rename to _py/test/pycollect.py index 0da86e374..c0aff1631 100644 --- a/py/test/pycollect.py +++ b/_py/test/pycollect.py @@ -18,9 +18,9 @@ a tree of collectors and test items that this modules provides:: """ import py import inspect -from py.__.test.collect import configproperty, warnoldcollect -pydir = py.path.local(py.__file__).dirpath() -from py.__.test import funcargs +from _py.test.collect import configproperty, warnoldcollect +pydir = py.path.local(py._py.__file__).dirpath() +from _py.test import funcargs class PyobjMixin(object): def obj(): diff --git a/py/test/session.py b/_py/test/session.py similarity index 99% rename from py/test/session.py rename to _py/test/session.py index 16334c9a5..122095c49 100644 --- a/py/test/session.py +++ b/_py/test/session.py @@ -6,7 +6,7 @@ """ import py -from py.__.test import outcome +from _py.test import outcome # imports used for genitems() Item = py.test.collect.Item diff --git a/_py/test/web/__init__.py b/_py/test/web/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/py/test/web/exception.py b/_py/test/web/exception.py similarity index 100% rename from py/test/web/exception.py rename to _py/test/web/exception.py diff --git a/py/test/web/post_multipart.py b/_py/test/web/post_multipart.py similarity index 100% rename from py/test/web/post_multipart.py rename to _py/test/web/post_multipart.py diff --git a/py/test/web/webcheck.py b/_py/test/web/webcheck.py similarity index 100% rename from py/test/web/webcheck.py rename to _py/test/web/webcheck.py diff --git a/py/thread/__init__.py b/_py/thread/__init__.py similarity index 100% rename from py/thread/__init__.py rename to _py/thread/__init__.py diff --git a/py/thread/io.py b/_py/thread/io.py similarity index 100% rename from py/thread/io.py rename to _py/thread/io.py diff --git a/py/thread/pool.py b/_py/thread/pool.py similarity index 100% rename from py/thread/pool.py rename to _py/thread/pool.py diff --git a/py/xmlgen.py b/_py/xmlgen.py similarity index 100% rename from py/xmlgen.py rename to _py/xmlgen.py diff --git a/bin-for-dist/gensetup.py b/bin-for-dist/gensetup.py index 8e13e0644..ffc0b3c69 100644 --- a/bin-for-dist/gensetup.py +++ b/bin-for-dist/gensetup.py @@ -27,14 +27,14 @@ class SetupWriter(object): def getallpath(self, basedir): contrib = self.basedir.join("contrib") - allpath = [] - lines = py.process.cmdexec("hg st -mcan").split("\n") - for path in lines: - p = basedir.join(path) - assert p.check(), p + allpath = [] + lines = py.process.cmdexec("hg st -mcan").split("\n") + for path in lines: + p = basedir.join(path) + assert p.check(), p if not p.relto(contrib) and p != contrib and not self.isexcluded(p): - allpath.append(p) - return allpath + allpath.append(p) + return allpath def append(self, string): lines = string.split("\n") @@ -70,37 +70,19 @@ class SetupWriter(object): ) for line in output.split("\n"): info.append("%s %s" %(indent, line.strip())) - return "\n".join(info) + return "\n".join(info) finally: old.chdir() def setup_header(self): #tooltime = "%s %s" %(py.std.time.asctime(), py.std.time.tzname[0]) - toolname = toolpath.basename - #toolrevision = py.path.svnwc(toolpath).info().rev - + toolname = toolpath.basename + #toolrevision = py.path.svnwc(toolpath).info().rev + pkgname = self.pkg.__name__ - info = self.tip_info() - self.append(''' - """ - py lib / py.test setup.py file, autogenerated by %(toolname)s - ''' % locals()) - #self.append(info) - self.append(''' - """ - import os, sys - ''') - - if self.setuptools: - #import ez_setup - #ez_setup.use_setuptools() - self.append(""" - from setuptools import setup - """) - else: - self.append(""" - from distutils.core import setup - """) + self.append('"""py lib / py.test setup.py file"""') + self.append('import os, sys') + self.append("from setuptools import setup") def setup_trailer(self): self.append(''' @@ -111,10 +93,6 @@ class SetupWriter(object): def setup_function(self): params = self.__dict__.copy() params.update(self.meta.__dict__) - #params['url'] = self.wcinfo.url - #params['rev'] = self.wcinfo.rev - #params['long_description'] = reformat(params['long_description']) - #print py.std.pprint.pprint(params) self.append('long_description = """') for line in params['long_description'].split('\n'): self.append(line) @@ -128,31 +106,26 @@ class SetupWriter(object): setup( name=%(name)r, description=%(description)r, - long_description = long_description, - version= trunk or %(version)r, - url=%(url)r, + long_description = long_description, + version= trunk or %(version)r, + url=%(url)r, license=%(license)r, - platforms=%(platforms)r, + platforms=%(platforms)r, author=%(author)r, author_email=%(author_email)r, ''' % params) indent = " " * 8 - #self.append_pprint(indent, py_modules=['_findpy',]), - #self.append_pprint(indent, scripts=self.getscripts()) self.append_pprint(indent, entry_points={'console_scripts':self.getconsolescripts()}) self.append_pprint(indent, classifiers=self.meta.classifiers) self.append_pprint(indent, packages=self.getpackages()) - #self.append_pprint(indent, data_files=self.getdatafiles()) self.append_pprint(indent, package_data=self.getpackagedata()) - #self.append_pprint(indent, package_dir={'py': 'py'}) - #self.append_pprint(indent, packages=self.getpackages()) - if self.setuptools: - self.append_pprint(indent, zip_safe=False) + self.append_pprint(indent, zip_safe=True) + self.append_pprint(indent, install_requires=['apipkg']) self.lines.append(indent[4:] + ")\n") def setup_scripts(self): # XXX this was used for a different approach - not used + not used self.append(""" def getscripts(): if sys.platform == "win32": @@ -164,7 +137,7 @@ class SetupWriter(object): l = [] for name in %r: l.append(base + name + ext) - return l + return l """ % ([script.basename for script in binpath.listdir("py.*")])) def append_pprint(self, indent, append=",", **kw): @@ -187,10 +160,10 @@ class SetupWriter(object): if p.dirpath() == bindir: if p.basename.startswith('py.'): shortname = "py" + p.basename[3:] - scripts.append("%s = py.cmdline:%s" % + scripts.append("%s = py.cmdline:%s" % (p.basename, shortname)) return scripts - + def getscripts(self): bindir = self.basedir.join('py', 'bin') scripts = [] @@ -202,7 +175,7 @@ class SetupWriter(object): def getpackages(self): packages = [] - for p in self.allpaths: # contains no directories! + for p in self.allpaths: # contains no directories! #if p.basename == "py": # continue if p.dirpath('__init__.py').check(): @@ -224,7 +197,7 @@ class SetupWriter(object): datafiles = [] pkgbase = self.basedir.join(self.pkg.__name__) for p in self.allpaths: - if p.check(file=1) and (not p.dirpath("__init__.py").check() + if p.check(file=1) and (not p.dirpath("__init__.py").check() or p.ext != ".py"): if p.dirpath() != self.basedir: x = p.relto(pkgbase) @@ -244,7 +217,7 @@ class SetupWriter(object): import winpath self.append(py.std.inspect.getsource(winpath)) self.append(""" - from distutils.command.install import install + from distutils.command.install import install class my_install(install): def finalize_other(self): install.finalize_other(self) @@ -281,7 +254,7 @@ class SetupWriter(object): else: cmdclass = {} ''') - + def write_setup(self): self.setup_header() self.setup_function() diff --git a/doc/changelog.txt b/doc/changelog.txt index 7e1d3ad94..d737a35ff 100644 --- a/doc/changelog.txt +++ b/doc/changelog.txt @@ -1,6 +1,9 @@ -Changes between 1.0.x and 'trunk' +Changes between 1.0.2 and '1.1.0b1' ===================================== +* make bpython/help interaction work by adding an __all__ attribute + to ApiModule, cleanup initpkg + * use MIT license for pylib, add some contributors * remove py.execnet code and substitute all usages with 'execnet' proper diff --git a/py/__init__.py b/py/__init__.py index d6a2ea3b2..67520cb37 100644 --- a/py/__init__.py +++ b/py/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- """ -advanced testing and development support library: +py.test and pylib: rapid testing and development utils - `py.test`_: cross-project testing tool with many advanced features - `py.path`_: path abstractions over local and subversion files @@ -11,191 +11,177 @@ For questions please check out http://pylib.org/contact.html .. _`py.test`: http://pylib.org/test.html .. _`py.path`: http://pylib.org/path.html -.. _`py.code`: http://pylib.org/code.html +.. _`py.code`: http://pylib.org/html (c) Holger Krekel and others, 2009 """ -from py.initpkg import initpkg -trunk = "1.1.0b1" +version = "1.1.0b1" -version = trunk or "1.0.x" +__version__ = version = version or "1.1.x" +import _py.apipkg -del trunk +_py.apipkg.initpkg(__name__, dict( + # access to all standard lib modules + std = '_py.std:std', + # access to all posix errno's as classes + error = '_py.error:error', -initpkg(__name__, - description = "py.test and pylib: rapid testing and high-level path/code objects.", - version = version, - url = "http://pylib.org", - license = "MIT license", - platforms = ['unix', 'linux', 'osx', 'cygwin', 'win32'], - author = "holger krekel, Guido Wesdorp, Carl Friedrich Bolz, Armin Rigo, Maciej Fijalkowski & others", - author_email = "holger at merlinux.eu, py-dev at codespeak.net", - long_description = globals()['__doc__'], - classifiers = [ - "Development Status :: 4 - Beta", - "Intended Audience :: Developers", - "License :: OSI Approved :: MIT License", - "Operating System :: POSIX", - "Operating System :: Microsoft :: Windows", - "Operating System :: MacOS :: MacOS X", - "Topic :: Software Development :: Testing", - "Topic :: Software Development :: Libraries", - "Topic :: System :: Distributed Computing", - "Topic :: Utilities", - "Programming Language :: Python", - ], + _com = { + 'Registry': '_py._com:Registry', + 'MultiCall': '_py._com:MultiCall', + 'comregistry': '_py._com:comregistry', + 'HookRelay': '_py._com:HookRelay', + }, + cmdline = { + 'pytest': '_py.cmdline.pytest:main', + 'pyrest': '_py.cmdline.pyrest:main', + 'pylookup': '_py.cmdline.pylookup:main', + 'pycountloc': '_py.cmdline.pycountlog:main', + 'pytest': '_py.test.cmdline:main', + 'pyrest': '_py.cmdline.pyrest:main', + 'pylookup': '_py.cmdline.pylookup:main', + 'pycountloc': '_py.cmdline.pycountloc:main', + 'pycleanup': '_py.cmdline.pycleanup:main', + 'pywhich' : '_py.cmdline.pywhich:main', + 'pysvnwcrevert' : '_py.cmdline.pysvnwcrevert:main', + 'pyconvert_unittest' : '_py.cmdline.pyconvert_unittest:main', + }, - # EXPORTED API - exportdefs = { - - # py lib events and plugins - '_com.Registry' : ('./_com.py', 'Registry'), - '_com.MultiCall' : ('./_com.py', 'MultiCall'), - '_com.comregistry' : ('./_com.py', 'comregistry'), - '_com.HookRelay' : ('./_com.py', 'HookRelay'), - - # py lib cmdline tools - 'cmdline.pytest' : ('./cmdline/pytest.py', 'main',), - 'cmdline.pyrest' : ('./cmdline/pyrest.py', 'main',), - 'cmdline.pylookup' : ('./cmdline/pylookup.py', 'main',), - 'cmdline.pycountloc' : ('./cmdline/pycountloc.py', 'main',), - 'cmdline.pycleanup' : ('./cmdline/pycleanup.py', 'main',), - 'cmdline.pywhich' : ('./cmdline/pywhich.py', 'main',), - 'cmdline.pysvnwcrevert' : ('./cmdline/pysvnwcrevert.py', 'main',), - 'cmdline.pyconvert_unittest' : ('./cmdline/pyconvert_unittest.py', 'main',), - - # helpers for use from test functions or collectors - 'test.__doc__' : ('./test/__init__.py', '__doc__'), - 'test._PluginManager' : ('./test/pluginmanager.py', 'PluginManager'), - 'test.raises' : ('./test/outcome.py', 'raises'), - 'test.skip' : ('./test/outcome.py', 'skip'), - 'test.importorskip' : ('./test/outcome.py', 'importorskip'), - 'test.fail' : ('./test/outcome.py', 'fail'), - 'test.exit' : ('./test/outcome.py', 'exit'), - - # configuration/initialization related test api - 'test.config' : ('./test/config.py', 'config_per_process'), - 'test.ensuretemp' : ('./test/config.py', 'ensuretemp'), - 'test.cmdline.main' : ('./test/cmdline.py', 'main'), - - # for customization of collecting/running tests - 'test.collect.Collector' : ('./test/collect.py', 'Collector'), - 'test.collect.Directory' : ('./test/collect.py', 'Directory'), - 'test.collect.File' : ('./test/collect.py', 'File'), - 'test.collect.Item' : ('./test/collect.py', 'Item'), - 'test.collect.Module' : ('./test/pycollect.py', 'Module'), - 'test.collect.Class' : ('./test/pycollect.py', 'Class'), - 'test.collect.Instance' : ('./test/pycollect.py', 'Instance'), - 'test.collect.Generator' : ('./test/pycollect.py', 'Generator'), - 'test.collect.Function' : ('./test/pycollect.py', 'Function'), - 'test.collect._fillfuncargs' : ('./test/funcargs.py', 'fillfuncargs'), - - # thread related API (still in early design phase) - '_thread.WorkerPool' : ('./thread/pool.py', 'WorkerPool'), - '_thread.NamedThreadPool' : ('./thread/pool.py', 'NamedThreadPool'), - '_thread.ThreadOut' : ('./thread/io.py', 'ThreadOut'), + test = { + # helpers for use from test functions or collectors + '__doc__' : '_py.test:__doc__', + '_PluginManager' : '_py.test.pluginmanager:PluginManager', + 'raises' : '_py.test.outcome:raises', + 'skip' : '_py.test.outcome:skip', + 'importorskip' : '_py.test.outcome:importorskip', + 'fail' : '_py.test.outcome:fail', + 'exit' : '_py.test.outcome:exit', + # configuration/initialization related test api + 'config' : '_py.test.config:config_per_process', + 'ensuretemp' : '_py.test.config:ensuretemp', + 'collect': { + 'Collector' : '_py.test.collect:Collector', + 'Directory' : '_py.test.collect:Directory', + 'File' : '_py.test.collect:File', + 'Item' : '_py.test.collect:Item', + 'Module' : '_py.test.pycollect:Module', + 'Class' : '_py.test.pycollect:Class', + 'Instance' : '_py.test.pycollect:Instance', + 'Generator' : '_py.test.pycollect:Generator', + 'Function' : '_py.test.pycollect:Function', + '_fillfuncargs' : '_py.test.funcargs:fillfuncargs', + }, + }, # hook into the top-level standard library - 'std' : ('./std.py', 'std'), + process = { + '__doc__' : '_py.process:__doc__', + 'cmdexec' : '_py.process.cmdexec:cmdexec', + 'kill' : '_py.process.killproc:kill', + 'ForkedFunc' : '_py.process.forkedfunc:ForkedFunc', + }, - 'process.__doc__' : ('./process/__init__.py', '__doc__'), - 'process.cmdexec' : ('./process/cmdexec.py', 'cmdexec'), - 'process.kill' : ('./process/killproc.py', 'kill'), - 'process.ForkedFunc' : ('./process/forkedfunc.py', 'ForkedFunc'), - - # path implementation - 'path.__doc__' : ('./path/__init__.py', '__doc__'), - 'path.svnwc' : ('./path/svnwc.py', 'SvnWCCommandPath'), - 'path.svnurl' : ('./path/svnurl.py', 'SvnCommandPath'), - 'path.local' : ('./path/local.py', 'LocalPath'), - 'path.SvnAuth' : ('./path/svnwc.py', 'SvnAuth'), + path = { + '__doc__' : '_py.path:__doc__', + 'svnwc' : '_py.path.svnwc:SvnWCCommandPath', + 'svnurl' : '_py.path.svnurl:SvnCommandPath', + 'local' : '_py.path.local:LocalPath', + 'SvnAuth' : '_py.path.svnwc:SvnAuth', + }, # some nice slightly magic APIs - #'magic.__doc__' : ('./magic/__init__.py', '__doc__'), - 'magic.invoke' : ('./code/oldmagic.py', 'invoke'), - 'magic.revoke' : ('./code/oldmagic.py', 'revoke'), - 'magic.patch' : ('./code/oldmagic.py', 'patch'), - 'magic.revert' : ('./code/oldmagic.py', 'revert'), - 'magic.autopath' : ('./path/local.py', 'autopath'), - 'magic.AssertionError' : ('./code/oldmagic2.py', 'AssertionError'), + magic = { + 'invoke' : '_py.code.oldmagic:invoke', + 'revoke' : '_py.code.oldmagic:revoke', + 'patch' : '_py.code.oldmagic:patch', + 'revert' : '_py.code.oldmagic:revert', + 'autopath' : '_py.path.local:autopath', + 'AssertionError' : '_py.code.oldmagic2:AssertionError', + }, # python inspection/code-generation API - 'code.__doc__' : ('./code/__init__.py', '__doc__'), - 'code.compile' : ('./code/source.py', 'compile_'), - 'code.Source' : ('./code/source.py', 'Source'), - 'code.Code' : ('./code/code.py', 'Code'), - 'code.Frame' : ('./code/code.py', 'Frame'), - 'code.ExceptionInfo' : ('./code/code.py', 'ExceptionInfo'), - 'code.Traceback' : ('./code/code.py', 'Traceback'), - 'code.getfslineno' : ('./code/source.py', 'getfslineno'), - 'code.getrawcode' : ('./code/code.py', 'getrawcode'), - 'code.patch_builtins' : ('./code/code.py', 'patch_builtins'), - 'code.unpatch_builtins' : ('./code/code.py', 'unpatch_builtins'), - 'code._AssertionError' : ('./code/assertion.py', 'AssertionError'), + code = { + '__doc__' : '_py.code:__doc__', + 'compile' : '_py.code.source:compile_', + 'Source' : '_py.code.source:Source', + 'Code' : '_py.code.code:Code', + 'Frame' : '_py.code.code:Frame', + 'ExceptionInfo' : '_py.code.code:ExceptionInfo', + 'Traceback' : '_py.code.code:Traceback', + 'getfslineno' : '_py.code.source:getfslineno', + 'getrawcode' : '_py.code.code:getrawcode', + 'patch_builtins' : '_py.code.code:patch_builtins', + 'unpatch_builtins' : '_py.code.code:unpatch_builtins', + '_AssertionError' : '_py.code.assertion:AssertionError', + }, # backports and additions of builtins - 'builtin.__doc__' : ('./builtin/__init__.py', '__doc__'), - 'builtin.enumerate' : ('./builtin/builtin24.py', 'enumerate'), - 'builtin.reversed' : ('./builtin/builtin24.py', 'reversed'), - 'builtin.sorted' : ('./builtin/builtin24.py', 'sorted'), - 'builtin.set' : ('./builtin/builtin24.py', 'set'), - 'builtin.frozenset' : ('./builtin/builtin24.py', 'frozenset'), - 'builtin.BaseException' : ('./builtin/builtin25.py', 'BaseException'), - 'builtin.GeneratorExit' : ('./builtin/builtin25.py', 'GeneratorExit'), - 'builtin.print_' : ('./builtin/builtin31.py', 'print_'), - 'builtin._reraise' : ('./builtin/builtin31.py', '_reraise'), - 'builtin._tryimport' : ('./builtin/builtin31.py', '_tryimport'), - 'builtin.exec_' : ('./builtin/builtin31.py', 'exec_'), - 'builtin._basestring' : ('./builtin/builtin31.py', '_basestring'), - 'builtin._totext' : ('./builtin/builtin31.py', '_totext'), - 'builtin._isbytes' : ('./builtin/builtin31.py', '_isbytes'), - 'builtin._istext' : ('./builtin/builtin31.py', '_istext'), - 'builtin._getimself' : ('./builtin/builtin31.py', '_getimself'), - 'builtin._getfuncdict' : ('./builtin/builtin31.py', '_getfuncdict'), - 'builtin.builtins' : ('./builtin/builtin31.py', 'builtins'), - 'builtin.execfile' : ('./builtin/builtin31.py', 'execfile'), - 'builtin.callable' : ('./builtin/builtin31.py', 'callable'), + builtin = { + '__doc__' : '_py.builtin:__doc__', + 'enumerate' : '_py.builtin.builtin24:enumerate', + 'reversed' : '_py.builtin.builtin24:reversed', + 'sorted' : '_py.builtin.builtin24:sorted', + 'set' : '_py.builtin.builtin24:set', + 'frozenset' : '_py.builtin.builtin24:frozenset', + 'BaseException' : '_py.builtin.builtin25:BaseException', + 'GeneratorExit' : '_py.builtin.builtin25:GeneratorExit', + 'print_' : '_py.builtin.builtin31:print_', + '_reraise' : '_py.builtin.builtin31:_reraise', + '_tryimport' : '_py.builtin.builtin31:_tryimport', + 'exec_' : '_py.builtin.builtin31:exec_', + '_basestring' : '_py.builtin.builtin31:_basestring', + '_totext' : '_py.builtin.builtin31:_totext', + '_isbytes' : '_py.builtin.builtin31:_isbytes', + '_istext' : '_py.builtin.builtin31:_istext', + '_getimself' : '_py.builtin.builtin31:_getimself', + '_getfuncdict' : '_py.builtin.builtin31:_getfuncdict', + 'builtins' : '_py.builtin.builtin31:builtins', + 'execfile' : '_py.builtin.builtin31:execfile', + 'callable' : '_py.builtin.builtin31:callable', + }, - # input-output helping - 'io.__doc__' : ('./io/__init__.py', '__doc__'), - 'io.dupfile' : ('./io/capture.py', 'dupfile'), - 'io.TextIO' : ('./io/capture.py', 'TextIO'), - 'io.BytesIO' : ('./io/capture.py', 'BytesIO'), - 'io.FDCapture' : ('./io/capture.py', 'FDCapture'), - 'io.StdCapture' : ('./io/capture.py', 'StdCapture'), - 'io.StdCaptureFD' : ('./io/capture.py', 'StdCaptureFD'), - 'io.TerminalWriter' : ('./io/terminalwriter.py', 'TerminalWriter'), - - # error module, defining all errno's as Classes - 'error' : ('./error.py', 'error'), + # input-output helping + io = { + '__doc__' : '_py.io:__doc__', + 'dupfile' : '_py.io.capture:dupfile', + 'TextIO' : '_py.io.capture:TextIO', + 'BytesIO' : '_py.io.capture:BytesIO', + 'FDCapture' : '_py.io.capture:FDCapture', + 'StdCapture' : '_py.io.capture:StdCapture', + 'StdCaptureFD' : '_py.io.capture:StdCaptureFD', + 'TerminalWriter' : '_py.io.terminalwriter:TerminalWriter', + }, # small and mean xml/html generation - 'xml.__doc__' : ('./xmlgen.py', '__doc__'), - 'xml.html' : ('./xmlgen.py', 'html'), - 'xml.Tag' : ('./xmlgen.py', 'Tag'), - 'xml.raw' : ('./xmlgen.py', 'raw'), - 'xml.Namespace' : ('./xmlgen.py', 'Namespace'), - 'xml.escape' : ('./xmlgen.py', 'escape'), + xml = { + '__doc__' : '_py.xmlgen:__doc__', + 'html' : '_py.xmlgen:html', + 'Tag' : '_py.xmlgen:Tag', + 'raw' : '_py.xmlgen:raw', + 'Namespace' : '_py.xmlgen:Namespace', + 'escape' : '_py.xmlgen:escape', + }, - # logging API ('producers' and 'consumers' connected via keywords) - 'log.__doc__' : ('./log/__init__.py', '__doc__'), - 'log._apiwarn' : ('./log/warning.py', '_apiwarn'), - 'log.Producer' : ('./log/log.py', 'Producer'), - 'log.setconsumer' : ('./log/log.py', 'setconsumer'), - 'log._setstate' : ('./log/log.py', 'setstate'), - 'log._getstate' : ('./log/log.py', 'getstate'), - 'log.Path' : ('./log/log.py', 'Path'), - 'log.STDOUT' : ('./log/log.py', 'STDOUT'), - 'log.STDERR' : ('./log/log.py', 'STDERR'), - 'log.Syslog' : ('./log/log.py', 'Syslog'), + log = { + # logging API ('producers' and 'consumers' connected via keywords) + '__doc__' : '_py.log:__doc__', + '_apiwarn' : '_py.log.warning:_apiwarn', + 'Producer' : '_py.log.log:Producer', + 'setconsumer' : '_py.log.log:setconsumer', + '_setstate' : '_py.log.log:setstate', + '_getstate' : '_py.log.log:getstate', + 'Path' : '_py.log.log:Path', + 'STDOUT' : '_py.log.log:STDOUT', + 'STDERR' : '_py.log.log:STDERR', + 'Syslog' : '_py.log.log:Syslog', + }, # compatibility modules (deprecated) - 'compat.__doc__' : ('./compat/__init__.py', '__doc__'), - 'compat.doctest' : ('./compat/dep_doctest.py', 'doctest'), - 'compat.optparse' : ('./compat/dep_optparse.py', 'optparse'), - 'compat.textwrap' : ('./compat/dep_textwrap.py', 'textwrap'), - 'compat.subprocess' : ('./compat/dep_subprocess.py', 'subprocess'), -}) - - - + compat = { + '__doc__' : '_py.compat:__doc__', + 'doctest' : '_py.compat.dep_doctest:doctest', + 'optparse' : '_py.compat.dep_optparse:optparse', + 'textwrap' : '_py.compat.dep_textwrap:textwrap', + 'subprocess' : '_py.compat.dep_subprocess:subprocess', + }, +)) diff --git a/py/initpkg.py b/py/initpkg.py deleted file mode 100644 index 3e7425117..000000000 --- a/py/initpkg.py +++ /dev/null @@ -1,235 +0,0 @@ -""" -package initialization. - -You use the functionality of this package by putting - - from py.initpkg import initpkg - initpkg(__name__, exportdefs={ - 'name1.name2' : ('./path/to/file.py', 'name') - ... - }) - -into your package's __init__.py file. This will -lead your package to only expose the names of all -your implementation files that you explicitely -specify. In the above example 'name1' will -become a Module instance where 'name2' is -bound in its namespace to the 'name' object -in the relative './path/to/file.py' python module. -Note that you can also use a '.c' file in which -case it will be compiled via distutils-facilities -on the fly. - -""" -from __future__ import generators -import sys -import os -assert sys.version_info >= (2,2,0), "py lib requires python 2.2 or higher" -from types import ModuleType - -# --------------------------------------------------- -# Package Object -# --------------------------------------------------- - -class Package(object): - def __init__(self, name, exportdefs, metainfo): - pkgmodule = sys.modules[name] - assert pkgmodule.__name__ == name - self.name = name - self.exportdefs = exportdefs - self.module = pkgmodule - assert not hasattr(pkgmodule, '__pkg__'), \ - "unsupported reinitialization of %r" % pkgmodule - pkgmodule.__pkg__ = self - - # make available pkgname.__ - implname = name + '.' + '__' - self.implmodule = ModuleType(implname) - self.implmodule.__name__ = implname - self.implmodule.__file__ = os.path.abspath(pkgmodule.__file__) - self.implmodule.__path__ = [os.path.abspath(p) - for p in pkgmodule.__path__] - pkgmodule.__ = self.implmodule - setmodule(implname, self.implmodule) - # inhibit further direct filesystem imports through the package module - del pkgmodule.__path__ - - # set metainfo - for name, value in metainfo.items(): - setattr(self, name, value) - version = metainfo.get('version', None) - if version: - pkgmodule.__version__ = version - - def _resolve(self, extpyish): - """ resolve a combined filesystem/python extpy-ish path. """ - fspath, modpath = extpyish - assert fspath.startswith('./'), \ - "%r is not an implementation path (XXX)" % (extpyish,) - implmodule = self._loadimpl(fspath[:-3]) - if not isinstance(modpath, str): # export the entire module - return implmodule - - current = implmodule - for x in modpath.split('.'): - try: - current = getattr(current, x) - except AttributeError: - raise AttributeError("resolving %r failed: %s" %( - extpyish, x)) - - return current - - def getimportname(self, path): - if not path.ext.startswith('.py'): - return None - import py - base = py.path.local(self.implmodule.__file__).dirpath() - if not path.relto(base): - return None - names = path.new(ext='').relto(base).split(path.sep) - dottedname = ".".join([self.implmodule.__name__] + names) - return dottedname - - def _loadimpl(self, relfile): - """ load implementation for the given relfile. """ - parts = [x.strip() for x in relfile.split('/') if x and x!= '.'] - modpath = ".".join([self.implmodule.__name__] + parts) - #print "trying import", modpath - return __import__(modpath, None, None, ['__doc__']) - - def exportitems(self): - return self.exportdefs.items() - - def getpath(self): - from py.path import local - base = local(self.implmodule.__file__).dirpath() - assert base.check() - return base - -def setmodule(modpath, module): - #print "sys.modules[%r] = %r" % (modpath, module) - sys.modules[modpath] = module - -# --------------------------------------------------- -# API Module Object -# --------------------------------------------------- - -class ApiModule(ModuleType): - def __init__(self, pkg, name): - self.__map__ = {} - self.__pkg__ = pkg - self.__name__ = name - - def __repr__(self): - return '' % (self.__name__,) - - def __getattr__(self, name): - if '*' in self.__map__: - extpy = self.__map__['*'][0], name - result = self.__pkg__._resolve(extpy) - else: - try: - extpy = self.__map__.pop(name) - except KeyError: - __tracebackhide__ = True - raise AttributeError(name) - else: - result = self.__pkg__._resolve(extpy) - - setattr(self, name, result) - #self._fixinspection(result, name) - return result - - def __setattr__(self, name, value): - super(ApiModule, self).__setattr__(name, value) - try: - del self.__map__[name] - except KeyError: - pass - - def _deprecated_fixinspection(self, result, name): - # modify some attrs to make a class appear at export level - if hasattr(result, '__module__'): - if not result.__module__.startswith('py.__'): - return # don't change __module__ nor __name__ for classes - # that the py lib re-exports from somewhere else, - # e.g. py.builtin.BaseException - try: - setattr(result, '__module__', self.__name__) - except (AttributeError, TypeError): - pass - if hasattr(result, '__bases__'): - try: - setattr(result, '__name__', name) - except (AttributeError, TypeError): - pass - - def getdict(self): - # force all the content of the module to be loaded when __dict__ is read - dictdescr = ModuleType.__dict__['__dict__'] - dict = dictdescr.__get__(self) - if dict is not None: - if '*' not in self.__map__: - for name in list(self.__map__): - hasattr(self, name) # force attribute load, ignore errors - assert not self.__map__, "%r not empty" % self.__map__ - else: - fsname = self.__map__['*'][0] - dict.update(self.__pkg__._loadimpl(fsname[:-3]).__dict__) - return dict - - __dict__ = property(getdict) - del getdict - -# --------------------------------------------------- -# Bootstrap Virtual Module Hierarchy -# --------------------------------------------------- - -def initpkg(pkgname, exportdefs, **kw): - #print "initializing package", pkgname - # bootstrap Package object - pkg = Package(pkgname, exportdefs, kw) - seen = { pkgname : pkg.module } - deferred_imports = [] - - for pypath, extpy in pkg.exportitems(): - pyparts = pypath.split('.') - modparts = pyparts[:] - if extpy[1] != '*': - lastmodpart = modparts.pop() - else: - lastmodpart = '*' - current = pkgname - - # ensure modules - for name in modparts: - previous = current - current += '.' + name - if current not in seen: - seen[current] = mod = ApiModule(pkg, current) - setattr(seen[previous], name, mod) - setmodule(current, mod) - - mod = seen[current] - if not hasattr(mod, '__map__'): - assert mod is pkg.module, \ - "only root modules are allowed to be non-lazy. " - deferred_imports.append((mod, pyparts[-1], extpy)) - else: - if extpy[1] == '__doc__': - mod.__doc__ = pkg._resolve(extpy) - else: - mod.__map__[lastmodpart] = extpy - - for mod, pypart, extpy in deferred_imports: - setattr(mod, pypart, pkg._resolve(extpy)) - - autoimport(pkgname) - -def autoimport(pkgname): - import py - ENVKEY = pkgname.upper() + "_AUTOIMPORT" - if ENVKEY in os.environ: - for impname in os.environ[ENVKEY].split(","): - __import__(impname) diff --git a/setup.py b/setup.py index e553fc732..d82a3654f 100644 --- a/setup.py +++ b/setup.py @@ -1,14 +1,9 @@ -""" -py lib / py.test setup.py file, autogenerated by gensetup.py - -""" +"""py lib / py.test setup.py file""" import os, sys - from setuptools import setup - long_description = """ -advanced testing and development support library: +py.test and pylib: rapid testing and development utils - `py.test`_: cross-project testing tool with many advanced features - `py.path`_: path abstractions over local and subversion files @@ -28,15 +23,14 @@ trunk = None def main(): setup( name='py', - description='py.test and pylib: rapid testing and high-level path/code objects.', - long_description = long_description, - version= trunk or '1.1.0b1', - url='http://pylib.org', + description='py.test and pylib: rapid testing and development utils.', + long_description = long_description, + version= trunk or '1.1.0b1', + url='http://pylib.org', license='MIT license', - platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'], + platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'], author='holger krekel, Guido Wesdorp, Carl Friedrich Bolz, Armin Rigo, Maciej Fijalkowski & others', - author_email='holger at merlinux.eu, py-dev at codespeak.net', - + author_email='holger at merlinux.eu', entry_points={'console_scripts': ['py.cleanup = py.cmdline:pycleanup', 'py.convert_unittest = py.cmdline:pyconvert_unittest', 'py.countloc = py.cmdline:pycountloc', @@ -57,22 +51,23 @@ def main(): 'Topic :: Utilities', 'Programming Language :: Python'], packages=['py', - 'py.builtin', - 'py.cmdline', - 'py.code', - 'py.compat', - 'py.io', - 'py.log', - 'py.path', - 'py.path.gateway', - 'py.process', - 'py.rest', - 'py.test', - 'py.test.dist', - 'py.test.looponfail', - 'py.test.plugin', - 'py.test.web', - 'py.thread'], + '_py', + '_py.builtin', + '_py.cmdline', + '_py.code', + '_py.compat', + '_py.io', + '_py.log', + '_py.path', + '_py.path.gateway', + '_py.process', + '_py.rest', + '_py.test', + '_py.test.dist', + '_py.test.looponfail', + '_py.test.plugin', + '_py.test.web', + '_py.thread'], package_data={'py': ['bin/_findpy.py', 'bin/env.cmd', 'bin/env.py', @@ -93,9 +88,9 @@ def main(): 'bin/win32/py.test.cmd', 'bin/win32/py.which.cmd', 'rest/rest.sty.template']}, - zip_safe=False, + zip_safe=True, ) if __name__ == '__main__': main() - \ No newline at end of file + diff --git a/testing/cmdline/test_convert_unittest.py b/testing/cmdline/test_convert_unittest.py index 87fc98760..1d434ea30 100644 --- a/testing/cmdline/test_convert_unittest.py +++ b/testing/cmdline/test_convert_unittest.py @@ -1,4 +1,4 @@ -from py.__.cmdline.pyconvert_unittest import rewrite_utest +from _py.cmdline.pyconvert_unittest import rewrite_utest class Test_UTestConvert: diff --git a/testing/code/test_assertion.py b/testing/code/test_assertion.py index 858ed3eca..2f131eb06 100644 --- a/testing/code/test_assertion.py +++ b/testing/code/test_assertion.py @@ -136,7 +136,7 @@ class TestView: def setup_class(cls): try: - from py.__.code._assertionold import View + from _py.code._assertionold import View except ImportError: py.test.skip("requires the compile package") cls.View = View diff --git a/testing/code/test_code.py b/testing/code/test_code.py index 8788862fb..872029343 100644 --- a/testing/code/test_code.py +++ b/testing/code/test_code.py @@ -1,7 +1,7 @@ from __future__ import generators import py import sys -from py.__.code.code import safe_repr +from _py.code.code import safe_repr def test_newcode(): source = "i = 3" @@ -157,7 +157,7 @@ class TestSafeRepr: assert 'TypeError' in safe_repr(BrokenRepr("string")) def test_big_repr(self): - from py.__.code.code import SafeRepr + from _py.code.code import SafeRepr assert len(safe_repr(range(1000))) <= \ len('[' + SafeRepr().maxlist * "1000" + ']') diff --git a/testing/code/test_excinfo.py b/testing/code/test_excinfo.py index 98238ea54..1afdb0463 100644 --- a/testing/code/test_excinfo.py +++ b/testing/code/test_excinfo.py @@ -1,6 +1,6 @@ import py -from py.__.code.code import FormattedExcinfo, ReprExceptionInfo +from _py.code.code import FormattedExcinfo, ReprExceptionInfo queue = py.builtin._tryimport('queue', 'Queue') class TWMock: @@ -112,8 +112,8 @@ class TestTraceback_f_g_h: def test_traceback_cut_excludepath(self, testdir): p = testdir.makepyfile("def f(): raise ValueError") excinfo = py.test.raises(ValueError, "p.pyimport().f()") - pydir = py.path.local(py.__file__).dirpath() - newtraceback = excinfo.traceback.cut(excludepath=pydir) + basedir = py.path.local(py._py.__file__).dirpath() + newtraceback = excinfo.traceback.cut(excludepath=basedir) assert len(newtraceback) == 1 assert newtraceback[0].frame.code.path == p diff --git a/testing/code/test_source.py b/testing/code/test_source.py index 951ed6b5d..bef0bdf7e 100644 --- a/testing/code/test_source.py +++ b/testing/code/test_source.py @@ -292,7 +292,7 @@ def test_getfuncsource_with_multine_string(): def test_deindent(): - from py.__.code.source import deindent as deindent + from _py.code.source import deindent as deindent assert deindent(['\tfoo', '\tbar', ]) == ['foo', 'bar'] def f(): @@ -331,27 +331,27 @@ if True: pass def test_getsource_fallback(): - from py.__.code.source import getsource + from _py.code.source import getsource expected = """def x(): pass""" src = getsource(x) assert src == expected def test_idem_compile_and_getsource(): - from py.__.code.source import getsource + from _py.code.source import getsource expected = "def x(): pass" co = py.code.compile(expected) src = getsource(co) assert src == expected def test_findsource_fallback(): - from py.__.code.source import findsource + from _py.code.source import findsource src, lineno = findsource(x) assert 'test_findsource_simple' in str(src) assert src[lineno] == ' def x():' def test_findsource___source__(): - from py.__.code.source import findsource + from _py.code.source import findsource co = py.code.compile("""if 1: def x(): pass diff --git a/testing/io_/test_capture.py b/testing/io_/test_capture.py index 869ace334..d5e2b6195 100644 --- a/testing/io_/test_capture.py +++ b/testing/io_/test_capture.py @@ -58,7 +58,7 @@ def test_bytes_io(): assert s == tobytes("hello") def test_dontreadfrominput(): - from py.__.io.capture import DontReadFromInput + from _py.io.capture import DontReadFromInput f = DontReadFromInput() assert not f.isatty() py.test.raises(IOError, f.read) diff --git a/testing/io_/test_terminalwriter.py b/testing/io_/test_terminalwriter.py index ca60b7080..982a6cd4b 100644 --- a/testing/io_/test_terminalwriter.py +++ b/testing/io_/test_terminalwriter.py @@ -1,6 +1,6 @@ import py import os, sys -from py.__.io import terminalwriter +from _py.io import terminalwriter def skip_win32(): if sys.platform == 'win32': diff --git a/testing/log/test_log.py b/testing/log/test_log.py index 0c2346fde..36c524cca 100644 --- a/testing/log/test_log.py +++ b/testing/log/test_log.py @@ -1,7 +1,7 @@ import py import sys -from py.__.log.log import default_keywordmapper +from _py.log.log import default_keywordmapper callcapture = py.io.StdCapture.call diff --git a/testing/path/conftest.py b/testing/path/conftest.py index ee80d315b..7b99eb9fb 100644 --- a/testing/path/conftest.py +++ b/testing/path/conftest.py @@ -1,5 +1,5 @@ import py -from py.__.path import svnwc as svncommon +from _py.path import svnwc as svncommon svnbin = py.path.local.sysfind('svn') repodump = py.path.local(__file__).dirpath('repotest.dump') diff --git a/testing/path/svntestbase.py b/testing/path/svntestbase.py index 153950dd2..0196809be 100644 --- a/testing/path/svntestbase.py +++ b/testing/path/svntestbase.py @@ -1,6 +1,6 @@ import sys import py -from py.__.path import svnwc as svncommon +from _py.path import svnwc as svncommon from testing.path.common import CommonFSTests class CommonSvnTests(CommonFSTests): diff --git a/testing/path/test_cacheutil.py b/testing/path/test_cacheutil.py index c374e83af..deb5f2bf9 100644 --- a/testing/path/test_cacheutil.py +++ b/testing/path/test_cacheutil.py @@ -1,5 +1,5 @@ import py -from py.__.path import cacheutil +from _py.path import cacheutil class BasicCacheAPITest: cache = None diff --git a/testing/path/test_svnurl.py b/testing/path/test_svnurl.py index 5d016e40b..3764c9021 100644 --- a/testing/path/test_svnurl.py +++ b/testing/path/test_svnurl.py @@ -1,5 +1,5 @@ import py -from py.__.path.svnurl import InfoSvnCommand +from _py.path.svnurl import InfoSvnCommand import datetime import time from testing.path.svntestbase import CommonSvnTests diff --git a/testing/path/test_svnwc.py b/testing/path/test_svnwc.py index f902dbabc..de612b720 100644 --- a/testing/path/test_svnwc.py +++ b/testing/path/test_svnwc.py @@ -1,7 +1,7 @@ import py import sys -from py.__.path.svnwc import InfoSvnWCCommand, XMLWCStatus, parse_wcinfotime -from py.__.path import svnwc as svncommon +from _py.path.svnwc import InfoSvnWCCommand, XMLWCStatus, parse_wcinfotime +from _py.path import svnwc as svncommon from testing.path.svntestbase import CommonSvnTests if sys.platform == 'win32': diff --git a/testing/process/test_cmdexec.py b/testing/process/test_cmdexec.py index 4d58fbc41..ad291d64f 100644 --- a/testing/process/test_cmdexec.py +++ b/testing/process/test_cmdexec.py @@ -30,7 +30,7 @@ class Test_exec_cmd: assert e.err or e.out def test_cmdexec_selection(): - from py.__.process import cmdexec + from _py.process import cmdexec if py.std.sys.platform == "win32": assert py.process.cmdexec == cmdexec.win32_exec_cmd elif hasattr(py.std.sys, 'pypy') or hasattr(py.std.sys, 'pypy_objspaceclass'): diff --git a/testing/pytest/dist/test_dsession.py b/testing/pytest/dist/test_dsession.py index 1a0078a67..9bcbe3026 100644 --- a/testing/pytest/dist/test_dsession.py +++ b/testing/pytest/dist/test_dsession.py @@ -1,5 +1,5 @@ -from py.__.test.dist.dsession import DSession -from py.__.test import outcome +from _py.test.dist.dsession import DSession +from _py.test import outcome import py import execnet diff --git a/testing/pytest/dist/test_gwmanage.py b/testing/pytest/dist/test_gwmanage.py index 452249317..82c20a422 100644 --- a/testing/pytest/dist/test_gwmanage.py +++ b/testing/pytest/dist/test_gwmanage.py @@ -7,8 +7,8 @@ import py import os -from py.__.test.dist.gwmanage import GatewayManager, HostRSync -from py.__.test.plugin import hookspec +from _py.test.dist.gwmanage import GatewayManager, HostRSync +from _py.test.plugin import hookspec import execnet def pytest_funcarg__hookrecorder(request): diff --git a/testing/pytest/dist/test_mypickle.py b/testing/pytest/dist/test_mypickle.py index 623dfc914..7597f5247 100644 --- a/testing/pytest/dist/test_mypickle.py +++ b/testing/pytest/dist/test_mypickle.py @@ -5,8 +5,8 @@ import execnet Queue = py.builtin._tryimport('queue', 'Queue').Queue -from py.__.test.dist.mypickle import ImmutablePickler, PickleChannel -from py.__.test.dist.mypickle import UnpickleError, makekey +from _py.test.dist.mypickle import ImmutablePickler, PickleChannel +from _py.test.dist.mypickle import UnpickleError, makekey # first let's test some basic functionality def pytest_generate_tests(metafunc): @@ -123,7 +123,7 @@ class TestPickleChannelFunctional: def test_popen_send_instance(self): channel = self.gw.remote_exec(""" - from py.__.test.dist.mypickle import PickleChannel + from _py.test.dist.mypickle import PickleChannel channel = PickleChannel(channel) from testing.pytest.dist.test_mypickle import A a1 = A() @@ -142,7 +142,7 @@ class TestPickleChannelFunctional: def test_send_concurrent(self): channel = self.gw.remote_exec(""" - from py.__.test.dist.mypickle import PickleChannel + from _py.test.dist.mypickle import PickleChannel channel = PickleChannel(channel) from testing.pytest.dist.test_mypickle import A l = [A() for i in range(10)] @@ -172,7 +172,7 @@ class TestPickleChannelFunctional: def test_popen_with_callback(self): channel = self.gw.remote_exec(""" - from py.__.test.dist.mypickle import PickleChannel + from _py.test.dist.mypickle import PickleChannel channel = PickleChannel(channel) from testing.pytest.dist.test_mypickle import A a1 = A() @@ -193,7 +193,7 @@ class TestPickleChannelFunctional: def test_popen_with_callback_with_endmarker(self): channel = self.gw.remote_exec(""" - from py.__.test.dist.mypickle import PickleChannel + from _py.test.dist.mypickle import PickleChannel channel = PickleChannel(channel) from testing.pytest.dist.test_mypickle import A a1 = A() @@ -217,7 +217,7 @@ class TestPickleChannelFunctional: def test_popen_with_callback_with_endmarker_and_unpickling_error(self): channel = self.gw.remote_exec(""" - from py.__.test.dist.mypickle import PickleChannel + from _py.test.dist.mypickle import PickleChannel channel = PickleChannel(channel) from testing.pytest.dist.test_mypickle import A a1 = A() @@ -236,7 +236,7 @@ class TestPickleChannelFunctional: def test_popen_with_newchannel(self): channel = self.gw.remote_exec(""" - from py.__.test.dist.mypickle import PickleChannel + from _py.test.dist.mypickle import PickleChannel channel = PickleChannel(channel) newchannel = channel.receive() newchannel.send(42) @@ -250,7 +250,7 @@ class TestPickleChannelFunctional: def test_popen_with_various_methods(self): channel = self.gw.remote_exec(""" - from py.__.test.dist.mypickle import PickleChannel + from _py.test.dist.mypickle import PickleChannel channel = PickleChannel(channel) channel.receive() """) diff --git a/testing/pytest/dist/test_nodemanage.py b/testing/pytest/dist/test_nodemanage.py index 8384349b7..4ae0258dc 100644 --- a/testing/pytest/dist/test_nodemanage.py +++ b/testing/pytest/dist/test_nodemanage.py @@ -1,5 +1,5 @@ import py -from py.__.test.dist.nodemanage import NodeManager +from _py.test.dist.nodemanage import NodeManager class pytest_funcarg__mysetup: def __init__(self, request): diff --git a/testing/pytest/dist/test_txnode.py b/testing/pytest/dist/test_txnode.py index 23935b2ee..867e39bff 100644 --- a/testing/pytest/dist/test_txnode.py +++ b/testing/pytest/dist/test_txnode.py @@ -1,7 +1,7 @@ import py import execnet -from py.__.test.dist.txnode import TXNode +from _py.test.dist.txnode import TXNode queue = py.builtin._tryimport("queue", "Queue") Queue = queue.Queue diff --git a/testing/pytest/looponfail/test_remote.py b/testing/pytest/looponfail/test_remote.py index 031db33e8..6923214e8 100644 --- a/testing/pytest/looponfail/test_remote.py +++ b/testing/pytest/looponfail/test_remote.py @@ -1,6 +1,6 @@ import py py.test.importorskip("execnet") -from py.__.test.looponfail.remote import LooponfailingSession, LoopState, RemoteControl +from _py.test.looponfail.remote import LooponfailingSession, LoopState, RemoteControl class TestRemoteControl: def test_nofailures(self, testdir): diff --git a/testing/pytest/looponfail/test_util.py b/testing/pytest/looponfail/test_util.py index 3a77f6f5b..70bc33600 100644 --- a/testing/pytest/looponfail/test_util.py +++ b/testing/pytest/looponfail/test_util.py @@ -1,5 +1,5 @@ import py -from py.__.test.looponfail.util import StatRecorder +from _py.test.looponfail.util import StatRecorder def test_filechange(tmpdir): tmp = tmpdir diff --git a/testing/pytest/plugin/conftest.py b/testing/pytest/plugin/conftest.py index bcd531cff..f19852f77 100644 --- a/testing/pytest/plugin/conftest.py +++ b/testing/pytest/plugin/conftest.py @@ -1,8 +1,8 @@ import py pytest_plugins = "pytester" -plugindir = py.path.local(py.__file__).dirpath('test', 'plugin') -from py.__.test.defaultconftest import pytest_plugins as default_plugins +plugindir = py.path.local(py._py.__file__).dirpath('test', 'plugin') +from _py.test.defaultconftest import pytest_plugins as default_plugins def pytest_collect_file(path, parent): if path.basename.startswith("pytest_") and path.ext == ".py": diff --git a/testing/pytest/plugin/test_pytest__pytest.py b/testing/pytest/plugin/test_pytest__pytest.py index 816dd8ee8..70aae80de 100644 --- a/testing/pytest/plugin/test_pytest__pytest.py +++ b/testing/pytest/plugin/test_pytest__pytest.py @@ -1,5 +1,5 @@ import py -from py.__.test.plugin.pytest__pytest import HookRecorder +from _py.test.plugin.pytest__pytest import HookRecorder def test_hookrecorder_basic(): comregistry = py._com.Registry() diff --git a/testing/pytest/plugin/test_pytest_capture.py b/testing/pytest/plugin/test_pytest_capture.py index d83620a09..08e342ec6 100644 --- a/testing/pytest/plugin/test_pytest_capture.py +++ b/testing/pytest/plugin/test_pytest_capture.py @@ -1,5 +1,5 @@ import py, os, sys -from py.__.test.plugin.pytest_capture import CaptureManager +from _py.test.plugin.pytest_capture import CaptureManager class TestCaptureManager: def test_getmethod_default_no_fd(self, testdir, monkeypatch): diff --git a/testing/pytest/plugin/test_pytest_default.py b/testing/pytest/plugin/test_pytest_default.py index 7c972ae73..98842a0e2 100644 --- a/testing/pytest/plugin/test_pytest_default.py +++ b/testing/pytest/plugin/test_pytest_default.py @@ -1,5 +1,5 @@ import py -from py.__.test.plugin.pytest_default import pytest_report_iteminfo +from _py.test.plugin.pytest_default import pytest_report_iteminfo def test_implied_different_sessions(tmpdir): def x(*args): diff --git a/testing/pytest/plugin/test_pytest_doctest.py b/testing/pytest/plugin/test_pytest_doctest.py index d57897947..c55715b5b 100644 --- a/testing/pytest/plugin/test_pytest_doctest.py +++ b/testing/pytest/plugin/test_pytest_doctest.py @@ -1,4 +1,4 @@ -from py.__.test.plugin.pytest_doctest import DoctestModule, DoctestTextfile +from _py.test.plugin.pytest_doctest import DoctestModule, DoctestTextfile class TestDoctests: @@ -33,7 +33,7 @@ class TestDoctests: reprec.assertoutcome(failed=1) def test_doctest_unexpected_exception(self, testdir): - from py.__.test.outcome import Failed + from _py.test.outcome import Failed p = testdir.maketxtfile(""" >>> i = 0 diff --git a/testing/pytest/plugin/test_pytest_keyword.py b/testing/pytest/plugin/test_pytest_keyword.py index 6baf4660a..ed904c68a 100644 --- a/testing/pytest/plugin/test_pytest_keyword.py +++ b/testing/pytest/plugin/test_pytest_keyword.py @@ -1,5 +1,5 @@ import py -from py.__.test.plugin.pytest_keyword import Mark +from _py.test.plugin.pytest_keyword import Mark def test_pytest_mark_api(): mark = Mark() diff --git a/testing/pytest/plugin/test_pytest_monkeypatch.py b/testing/pytest/plugin/test_pytest_monkeypatch.py index a81d2badb..14f30efda 100644 --- a/testing/pytest/plugin/test_pytest_monkeypatch.py +++ b/testing/pytest/plugin/test_pytest_monkeypatch.py @@ -1,6 +1,6 @@ import os, sys import py -from py.__.test.plugin.pytest_monkeypatch import MonkeyPatch +from _py.test.plugin.pytest_monkeypatch import MonkeyPatch def test_setattr(): class A: diff --git a/testing/pytest/plugin/test_pytest_pytester.py b/testing/pytest/plugin/test_pytest_pytester.py index 3fc3cd094..0c7d25ffe 100644 --- a/testing/pytest/plugin/test_pytest_pytester.py +++ b/testing/pytest/plugin/test_pytest_pytester.py @@ -1,5 +1,5 @@ import py -from py.__.test.plugin.pytest_pytester import LineMatcher, LineComp +from _py.test.plugin.pytest_pytester import LineMatcher, LineComp def test_reportrecorder(testdir): registry = py._com.Registry() diff --git a/testing/pytest/plugin/test_pytest_recwarn.py b/testing/pytest/plugin/test_pytest_recwarn.py index 543cdf41c..7b9a3992c 100644 --- a/testing/pytest/plugin/test_pytest_recwarn.py +++ b/testing/pytest/plugin/test_pytest_recwarn.py @@ -1,5 +1,5 @@ import py -from py.__.test.plugin.pytest_recwarn import WarningsRecorder +from _py.test.plugin.pytest_recwarn import WarningsRecorder def test_WarningRecorder(): showwarning = py.std.warnings.showwarning diff --git a/testing/pytest/plugin/test_pytest_restdoc.py b/testing/pytest/plugin/test_pytest_restdoc.py index f3423d767..4241cad6b 100644 --- a/testing/pytest/plugin/test_pytest_restdoc.py +++ b/testing/pytest/plugin/test_pytest_restdoc.py @@ -1,4 +1,4 @@ -from py.__.test.plugin.pytest_restdoc import deindent +from _py.test.plugin.pytest_restdoc import deindent def test_deindent(): assert deindent('foo') == 'foo' @@ -13,7 +13,7 @@ class TestApigenLinkRole: # these tests are moved here from the former py/doc/conftest.py def test_resolve_linkrole(self): - from py.__.doc.conftest import get_apigen_relpath + from _py.doc.conftest import get_apigen_relpath apigen_relpath = get_apigen_relpath() assert resolve_linkrole('api', 'py.foo.bar', False) == ( @@ -45,7 +45,7 @@ class TestDoctest: def pytest_funcarg__testdir(self, request): testdir = request.getfuncargvalue("testdir") assert request.module.__name__ == __name__ - testdir.makepyfile(confrest="from py.__.rest.resthtml import Project") + testdir.makepyfile(confrest="from _py.rest.resthtml import Project") for p in testdir.plugins: if p == globals(): break diff --git a/testing/pytest/plugin/test_pytest_resultlog.py b/testing/pytest/plugin/test_pytest_resultlog.py index 11430dff6..fd64b84bf 100644 --- a/testing/pytest/plugin/test_pytest_resultlog.py +++ b/testing/pytest/plugin/test_pytest_resultlog.py @@ -1,7 +1,7 @@ import py import os -from py.__.test.plugin.pytest_resultlog import generic_path, ResultLog -from py.__.test.collect import Node, Item, FSCollector +from _py.test.plugin.pytest_resultlog import generic_path, ResultLog +from _py.test.collect import Node, Item, FSCollector def test_generic_path(): p1 = Node('a') diff --git a/testing/pytest/plugin/test_pytest_runner.py b/testing/pytest/plugin/test_pytest_runner.py index 06c51dc87..5bb739daa 100644 --- a/testing/pytest/plugin/test_pytest_runner.py +++ b/testing/pytest/plugin/test_pytest_runner.py @@ -1,6 +1,6 @@ import py -from py.__.test.plugin import pytest_runner as runner -from py.__.code.code import ReprExceptionInfo +from _py.test.plugin import pytest_runner as runner +from _py.code.code import ReprExceptionInfo class TestSetupState: def test_setup(self, testdir): @@ -181,10 +181,10 @@ class BaseFunctionalTests: assert rep.when == "call" def test_exit_propagates(self, testdir): - from py.__.test.outcome import Exit + from _py.test.outcome import Exit try: testdir.runitem(""" - from py.__.test.outcome import Exit + from _py.test.outcome import Exit def test_func(): raise Exit() """) @@ -200,7 +200,7 @@ class TestExecutionNonForked(BaseFunctionalTests): return f def test_keyboardinterrupt_propagates(self, testdir): - from py.__.test.outcome import Exit + from _py.test.outcome import Exit try: testdir.runitem(""" def test_func(): diff --git a/testing/pytest/plugin/test_pytest_terminal.py b/testing/pytest/plugin/test_pytest_terminal.py index c0621a334..747b3d0aa 100644 --- a/testing/pytest/plugin/test_pytest_terminal.py +++ b/testing/pytest/plugin/test_pytest_terminal.py @@ -13,9 +13,9 @@ except ImportError: # # =============================================================================== -from py.__.test.plugin.pytest_terminal import TerminalReporter, \ +from _py.test.plugin.pytest_terminal import TerminalReporter, \ CollectonlyReporter, repr_pythonversion, folded_skips -from py.__.test.plugin import pytest_runner as runner +from _py.test.plugin import pytest_runner as runner def basic_run_report(item): return runner.call_and_report(item, "call", log=False) diff --git a/testing/pytest/plugin/test_pytest_tmpdir.py b/testing/pytest/plugin/test_pytest_tmpdir.py index 5c24bfc94..788432eeb 100644 --- a/testing/pytest/plugin/test_pytest_tmpdir.py +++ b/testing/pytest/plugin/test_pytest_tmpdir.py @@ -1,7 +1,7 @@ -from py.__.test.plugin.pytest_tmpdir import pytest_funcarg__tmpdir +from _py.test.plugin.pytest_tmpdir import pytest_funcarg__tmpdir def test_funcarg(testdir): - from py.__.test.funcargs import FuncargRequest + from _py.test.funcargs import FuncargRequest item = testdir.getitem("def test_func(tmpdir): pass") p = pytest_funcarg__tmpdir(FuncargRequest(item)) assert p.check() diff --git a/testing/pytest/test_collect.py b/testing/pytest/test_collect.py index a32f176db..e649e6013 100644 --- a/testing/pytest/test_collect.py +++ b/testing/pytest/test_collect.py @@ -2,7 +2,7 @@ import py class TestCollector: def test_collect_versus_item(self): - from py.__.test.collect import Collector, Item + from _py.test.collect import Collector, Item assert not issubclass(Collector, Item) assert not issubclass(Item, Collector) diff --git a/testing/pytest/test_compat.py b/testing/pytest/test_compat.py index 3c972ae79..88a7547ed 100644 --- a/testing/pytest/test_compat.py +++ b/testing/pytest/test_compat.py @@ -1,7 +1,7 @@ from __future__ import generators import py -from py.__.test.compat import TestCase -from py.__.test.outcome import Failed +from _py.test.compat import TestCase +from _py.test.outcome import Failed class TestCompatTestCaseSetupSemantics(TestCase): globlist = [] diff --git a/testing/pytest/test_config.py b/testing/pytest/test_config.py index 04011773f..c5142a420 100644 --- a/testing/pytest/test_config.py +++ b/testing/pytest/test_config.py @@ -107,7 +107,7 @@ class TestConfigAPI: py.test.raises(KeyError, 'config.getvalue("y", o)') def test_config_getvalueorskip(self, testdir): - from py.__.test.outcome import Skipped + from _py.test.outcome import Skipped config = testdir.parseconfig() py.test.raises(Skipped, "config.getvalueorskip('hello')") verbose = config.getvalueorskip("verbose") @@ -229,7 +229,7 @@ class TestOptionEffects: class TestConfig_gettopdir: def test_gettopdir(self, testdir): - from py.__.test.config import gettopdir + from _py.test.config import gettopdir tmp = testdir.tmpdir assert gettopdir([tmp]) == tmp topdir = gettopdir([tmp.join("hello"), tmp.join("world")]) @@ -238,7 +238,7 @@ class TestConfig_gettopdir: assert gettopdir([somefile]) == tmp def test_gettopdir_pypkg(self, testdir): - from py.__.test.config import gettopdir + from _py.test.config import gettopdir tmp = testdir.tmpdir a = tmp.ensure('a', dir=1) b = tmp.ensure('a', 'b', '__init__.py') diff --git a/testing/pytest/test_conftesthandle.py b/testing/pytest/test_conftesthandle.py index 9af9aeeeb..75a56112b 100644 --- a/testing/pytest/test_conftesthandle.py +++ b/testing/pytest/test_conftesthandle.py @@ -1,5 +1,5 @@ import py -from py.__.test.conftesthandle import Conftest +from _py.test.conftesthandle import Conftest def pytest_generate_tests(metafunc): if "basedir" in metafunc.funcargnames: diff --git a/testing/pytest/test_funcargs.py b/testing/pytest/test_funcargs.py index 795b9bc07..b640fb7fb 100644 --- a/testing/pytest/test_funcargs.py +++ b/testing/pytest/test_funcargs.py @@ -1,5 +1,5 @@ import py, sys -from py.__.test import funcargs +from _py.test import funcargs def test_getfuncargnames(): def f(): pass diff --git a/testing/pytest/test_outcome.py b/testing/pytest/test_outcome.py index 585bfdd6a..967bc72e1 100644 --- a/testing/pytest/test_outcome.py +++ b/testing/pytest/test_outcome.py @@ -16,7 +16,7 @@ class TestRaises: py.test.raises(ValueError, int, 'hello') def test_importorskip(): - from py.__.test.outcome import Skipped + from _py.test.outcome import Skipped try: sys = py.test.importorskip("sys") assert sys == py.std.sys diff --git a/testing/pytest/test_parseopt.py b/testing/pytest/test_parseopt.py index 6d344f246..299175c98 100644 --- a/testing/pytest/test_parseopt.py +++ b/testing/pytest/test_parseopt.py @@ -1,5 +1,5 @@ import py -from py.__.test import parseopt +from _py.test import parseopt class TestParser: def test_init(self, capsys): diff --git a/testing/pytest/test_pickling.py b/testing/pytest/test_pickling.py index 0bffcbcf8..64dc479e8 100644 --- a/testing/pytest/test_pickling.py +++ b/testing/pytest/test_pickling.py @@ -19,7 +19,7 @@ def pytest_funcarg__testdir(request): class ImmutablePickleTransport: def __init__(self, request): - from py.__.test.dist.mypickle import ImmutablePickler + from _py.test.dist.mypickle import ImmutablePickler self.p1 = ImmutablePickler(uneven=0) self.p2 = ImmutablePickler(uneven=1) setglobals(request) @@ -69,7 +69,7 @@ class TestImmutablePickling: class TestConfigPickling: def test_config_getstate_setstate(self, testdir): - from py.__.test.config import Config + from _py.test.config import Config testdir.makepyfile(__init__="", conftest="x=1; y=2") hello = testdir.makepyfile(hello="") tmp = testdir.tmpdir @@ -183,11 +183,11 @@ class TestConfigPickling: def test_config__setstate__wired_correctly_in_childprocess(testdir): execnet = py.test.importorskip("execnet") - from py.__.test.dist.mypickle import PickleChannel + from _py.test.dist.mypickle import PickleChannel gw = execnet.PopenGateway() channel = gw.remote_exec(""" import py - from py.__.test.dist.mypickle import PickleChannel + from _py.test.dist.mypickle import PickleChannel channel = PickleChannel(channel) config = channel.receive() assert py.test.config.pluginmanager.comregistry == py._com.comregistry, "comregistry wrong" diff --git a/testing/pytest/test_pluginmanager.py b/testing/pytest/test_pluginmanager.py index f180ba0c3..957a4e455 100644 --- a/testing/pytest/test_pluginmanager.py +++ b/testing/pytest/test_pluginmanager.py @@ -1,5 +1,5 @@ import py, os -from py.__.test.pluginmanager import PluginManager, canonical_importname, collectattr +from _py.test.pluginmanager import PluginManager, canonical_importname, collectattr class TestBootstrapping: def test_consider_env_fails_to_import(self, monkeypatch): @@ -162,7 +162,7 @@ class TestBootstrapping: class TestPytestPluginInteractions: def test_do_option_conftestplugin(self, testdir): - from py.__.test.config import Config + from _py.test.config import Config p = testdir.makepyfile(""" def pytest_addoption(parser): parser.addoption('--test123', action="store_true") @@ -190,7 +190,7 @@ class TestPytestPluginInteractions: ]) def test_do_option_postinitialize(self, testdir): - from py.__.test.config import Config + from _py.test.config import Config config = Config() config.parse([]) config.pluginmanager.do_configure(config=config) diff --git a/testing/pytest/test_pycollect.py b/testing/pytest/test_pycollect.py index 1a4d8c777..9e1c95ecb 100644 --- a/testing/pytest/test_pycollect.py +++ b/testing/pytest/test_pycollect.py @@ -1,6 +1,6 @@ import py -from py.__.test.outcome import Skipped +from _py.test.outcome import Skipped class TestModule: def test_module_file_not_found(self, testdir): diff --git a/testing/pytest/test_traceback.py b/testing/pytest/test_traceback.py index 9fd1230a7..868be6127 100644 --- a/testing/pytest/test_traceback.py +++ b/testing/pytest/test_traceback.py @@ -2,7 +2,7 @@ import py class TestTracebackCutting: def test_skip_simple(self): - from py.__.test.outcome import Skipped + from _py.test.outcome import Skipped excinfo = py.test.raises(Skipped, 'py.test.skip("xxx")') assert excinfo.traceback[-1].frame.code.name == "skip" assert excinfo.traceback[-1].ishidden() diff --git a/testing/rest/test_convert.py b/testing/rest/test_convert.py index ed7d05698..40d66d953 100644 --- a/testing/rest/test_convert.py +++ b/testing/rest/test_convert.py @@ -1,5 +1,5 @@ import py -from py.__.rest.convert import convert_dot, latexformula2png +from _py.rest.convert import convert_dot, latexformula2png from testing.rest.setup import getdata def setup_module(mod): diff --git a/testing/rest/test_directive.py b/testing/rest/test_directive.py index 132128cf1..7679fd730 100644 --- a/testing/rest/test_directive.py +++ b/testing/rest/test_directive.py @@ -1,8 +1,8 @@ import py docutils = py.test.importorskip("docutils") -from py.__.rest import directive, resthtml -from py.__.rest.latex import process_rest_file +from _py.rest import directive, resthtml +from _py.rest.latex import process_rest_file from testing.rest.setup import getdata def setup_module(mod): diff --git a/testing/rest/test_htmlrest.py b/testing/rest/test_htmlrest.py index 8f16b236b..c6de0a982 100644 --- a/testing/rest/test_htmlrest.py +++ b/testing/rest/test_htmlrest.py @@ -1,6 +1,6 @@ import py -from py.__.rest import resthtml +from _py.rest import resthtml from testing.rest.setup import getdata def setup_module(mod): diff --git a/testing/rest/test_rst2pdf.py b/testing/rest/test_rst2pdf.py index ae5102f00..6197b3e0a 100644 --- a/testing/rest/test_rst2pdf.py +++ b/testing/rest/test_rst2pdf.py @@ -1,5 +1,5 @@ import py -from py.__.rest.latex import process_configfile, process_rest_file +from _py.rest.latex import process_configfile, process_rest_file from testing.rest.setup import getdata docutils = py.test.importorskip("docutils") diff --git a/testing/root/test_com.py b/testing/root/test_com.py index c329cd442..3a9beaf2f 100644 --- a/testing/root/test_com.py +++ b/testing/root/test_com.py @@ -1,7 +1,7 @@ import py import os -from py.__._com import Registry, MultiCall, HookRelay, varnames +from _py._com import Registry, MultiCall, HookRelay, varnames def test_varnames(): def f(x): diff --git a/testing/root/test_initpkg.py b/testing/root/test_initpkg.py deleted file mode 100644 index 4f6ee3b1f..000000000 --- a/testing/root/test_initpkg.py +++ /dev/null @@ -1,184 +0,0 @@ -from __future__ import generators - -import py -import types -import sys - -def checksubpackage(name): - obj = getattr(py, name) - if hasattr(obj, '__map__'): # isinstance(obj, Module): - keys = dir(obj) - assert len(keys) > 0 - assert getattr(obj, '__map__') == {} - -def test_dir(): - from py.__.initpkg import ApiModule - for name in dir(py): - if name == 'magic': # greenlets don't work everywhere, we don't care here - continue - if not name.startswith('_'): - yield checksubpackage, name - -from py.initpkg import ApiModule -glob = [] -class MyModule(ApiModule): - def __init__(self, *args): - glob.append(self.__dict__) - assert isinstance(glob[-1], (dict, type(None))) - ApiModule.__init__(self, *args) - -def test_early__dict__access(): - mymod = MyModule("whatever", "myname") - assert isinstance(mymod.__dict__, dict) - -def test_resolve_attrerror(): - extpyish = "./initpkg.py", "hello" - excinfo = py.test.raises(AttributeError, "py.__pkg__._resolve(extpyish)") - s = str(excinfo.value) - assert s.find(extpyish[0]) != -1 - assert s.find(extpyish[1]) != -1 - -def test_virtual_module_identity(): - from py import path as path1 - from py import path as path2 - assert path1 is path2 - from py.path import local as local1 - from py.path import local as local2 - assert local1 is local2 - -def test_importall(): - base = py.path.local(py.__file__).dirpath() - nodirs = [ - base.join('test', 'testing', 'data'), - base.join('test', 'web'), - base.join('path', 'gateway',), - base.join('doc',), - base.join('rest', 'directive.py'), - base.join('test', 'testing', 'import_test'), - base.join('bin'), - base.join('code', 'oldmagic.py'), - base.join('execnet', 'script'), - base.join('compat', 'testing'), - ] - if sys.version_info >= (3,0): - nodirs.append(base.join('code', '_assertionold.py')) - else: - nodirs.append(base.join('code', '_assertionnew.py')) - - def recurse(p): - return p.check(dotfile=0) and p.basename != "attic" - - for p in base.visit('*.py', recurse): - if p.basename == '__init__.py': - continue - relpath = p.new(ext='').relto(base) - if base.sep in relpath: # not py/*.py itself - for x in nodirs: - if p == x or p.relto(x): - break - else: - relpath = relpath.replace(base.sep, '.') - modpath = 'py.__.%s' % relpath - check_import(modpath) - -def check_import(modpath): - py.builtin.print_("checking import", modpath) - assert __import__(modpath) - -# -# test support for importing modules -# - -class TestRealModule: - - def setup_class(cls): - cls.tmpdir = py.test.ensuretemp('test_initpkg') - sys.path = [str(cls.tmpdir)] + sys.path - pkgdir = cls.tmpdir.ensure('realtest', dir=1) - - tfile = pkgdir.join('__init__.py') - tfile.write(py.code.Source(""" - import py - py.initpkg('realtest', { - 'x.module.__doc__': ('./testmodule.py', '__doc__'), - 'x.module': ('./testmodule.py', '*'), - }) - """)) - - tfile = pkgdir.join('testmodule.py') - tfile.write(py.code.Source(""" - 'test module' - - __all__ = ['mytest0', 'mytest1', 'MyTest'] - - def mytest0(): - pass - def mytest1(): - pass - class MyTest: - pass - - """)) - - import realtest # need to mimic what a user would do - #py.initpkg('realtest', { - # 'module': ('./testmodule.py', None) - #}) - - def setup_method(self, *args): - """Unload the test modules before each test.""" - module_names = ['realtest', 'realtest.x', 'realtest.x.module'] - for modname in module_names: - if modname in sys.modules: - del sys.modules[modname] - - def test_realmodule(self): - """Testing 'import realtest.x.module'""" - import realtest.x.module - assert 'realtest.x.module' in sys.modules - assert getattr(realtest.x.module, 'mytest0') - - def test_realmodule_from(self): - """Testing 'from test import module'.""" - from realtest.x import module - assert getattr(module, 'mytest1') - - def test_realmodule_star(self): - """Testing 'from test.module import *'.""" - tfile = self.tmpdir.join('startest.py') - tfile.write(py.code.Source(""" - from realtest.x.module import * - globals()['mytest0'] - globals()['mytest1'] - globals()['MyTest'] - """)) - import startest # an exception will be raise if an error occurs - - def test_realmodule_dict_import(self): - "Test verifying that accessing the __dict__ invokes the import" - import realtest.x.module - moddict = realtest.x.module.__dict__ - assert 'mytest0' in moddict - assert 'mytest1' in moddict - assert 'MyTest' in moddict - - def test_realmodule___doc__(self): - """test whether the __doc__ attribute is set properly from initpkg""" - import realtest.x.module - assert realtest.x.module.__doc__ == 'test module' - -def test_autoimport(): - from py.initpkg import autoimport - py.std.os.environ['AUTOTEST_AUTOIMPORT'] = "nonexistmodule" - py.test.raises(ImportError, "autoimport('autotest')") - - -def test_all_resolves(): - seen = py.builtin.set([py]) - lastlength = None - while len(seen) != lastlength: - lastlength = len(seen) - for item in py.builtin.frozenset(seen): - for value in item.__dict__.values(): - if isinstance(value, type(py.test)): - seen.add(value) diff --git a/testing/root/test_xmlgen.py b/testing/root/test_xmlgen.py index e92297562..0e95d1a98 100644 --- a/testing/root/test_xmlgen.py +++ b/testing/root/test_xmlgen.py @@ -1,6 +1,6 @@ import py -from py.__.xmlgen import unicode, html +from _py.xmlgen import unicode, html class ns(py.xml.Namespace): pass diff --git a/testing/test_py_imports.py b/testing/test_py_imports.py new file mode 100644 index 000000000..bdf4972b4 --- /dev/null +++ b/testing/test_py_imports.py @@ -0,0 +1,73 @@ +import py +import types +import sys + +def checksubpackage(name): + obj = getattr(py, name) + if hasattr(obj, '__map__'): # isinstance(obj, Module): + keys = dir(obj) + assert len(keys) > 0 + assert getattr(obj, '__map__') == {} + +def test_dir(): + for name in dir(py): + if not name.startswith('_'): + yield checksubpackage, name + +def test_virtual_module_identity(): + from py import path as path1 + from py import path as path2 + assert path1 is path2 + from py.path import local as local1 + from py.path import local as local2 + assert local1 is local2 + +def test_importall(): + base = py.path.local(py.__file__).dirpath() + nodirs = [ + base.join('test', 'testing', 'data'), + base.join('test', 'web'), + base.join('path', 'gateway',), + base.join('doc',), + base.join('rest', 'directive.py'), + base.join('test', 'testing', 'import_test'), + base.join('bin'), + base.join('code', 'oldmagic.py'), + base.join('execnet', 'script'), + base.join('compat', 'testing'), + ] + if sys.version_info >= (3,0): + nodirs.append(base.join('code', '_assertionold.py')) + else: + nodirs.append(base.join('code', '_assertionnew.py')) + + def recurse(p): + return p.check(dotfile=0) and p.basename != "attic" + + for p in base.visit('*.py', recurse): + if p.basename == '__init__.py': + continue + relpath = p.new(ext='').relto(base) + if base.sep in relpath: # not py/*.py itself + for x in nodirs: + if p == x or p.relto(x): + break + else: + relpath = relpath.replace(base.sep, '.') + modpath = '_py.%s' % relpath + check_import(modpath) + +def check_import(modpath): + py.builtin.print_("checking import", modpath) + assert __import__(modpath) + +def test_all_resolves(): + seen = py.builtin.set([py]) + lastlength = None + while len(seen) != lastlength: + lastlength = len(seen) + for item in py.builtin.frozenset(seen): + for value in item.__dict__.values(): + if isinstance(value, type(py.test)): + seen.add(value) + diff --git a/testing/thread/test_pool.py b/testing/thread/test_pool.py index 20a2b1c32..ab20c3e8c 100644 --- a/testing/thread/test_pool.py +++ b/testing/thread/test_pool.py @@ -1,7 +1,7 @@ import py import sys -from py.__.thread.pool import queue +from _py.thread.pool import queue WorkerPool = py._thread.WorkerPool ThreadOut = py._thread.ThreadOut