rewrote the initpkg mechanism and moved py lib implementation files to

_py/...  with py/__init__.py containing pointers into them

The new apipkg is only around 70 lines of code and allows
us to get rid of the infamous "py.__." by regular non-magical
"_py." imports. It is also available as a separately installable
package, see http://bitbucket.org/hpk42/apipkg

--HG--
branch : trunk
This commit is contained in:
holger krekel
2009-10-03 01:47:39 +02:00
parent db1ff48996
commit 5791c06bf2
171 changed files with 447 additions and 844 deletions

View File

@@ -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

View File

@@ -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" + ']')

View File

@@ -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

View File

@@ -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