Skip to content

Commit fe77fd4

Browse files
committed
Move py.code to pytest.code pytest-dev#103
WIP, some tests still fail. Tests also need moving across.
1 parent c30eafa commit fe77fd4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+2415
-105
lines changed

_pytest/assertion/newinterpret.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import sys
77
import ast
88

9-
import py
9+
import pytest.code
1010
from _pytest.assertion import util
1111
from _pytest.assertion.reinterpret import BuiltinAssertionError
1212

@@ -63,7 +63,7 @@ def interpret(source, frame, should_fail=False):
6363

6464
def run(offending_line, frame=None):
6565
if frame is None:
66-
frame = py.code.Frame(sys._getframe(1))
66+
frame = pytest.code.Frame(sys._getframe(1))
6767
return interpret(offending_line, frame)
6868

6969
def getfailure(e):

_pytest/assertion/oldinterpret.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import traceback
22
import types
33
import py
4+
import pytest.code
45
import sys, inspect
56
from compiler import parse, ast, pycodegen
67
from _pytest.assertion.util import format_explanation, BuiltinAssertionError
@@ -456,7 +457,7 @@ def report_failure(e):
456457
def check(s, frame=None):
457458
if frame is None:
458459
frame = sys._getframe(1)
459-
frame = py.code.Frame(frame)
460+
frame = pytest.code.Frame(frame)
460461
expr = parse(s, 'eval')
461462
assert isinstance(expr, ast.Expression)
462463
node = Interpretable(expr.node)
@@ -480,7 +481,7 @@ def interpret(source, frame, should_fail=False):
480481
module = Interpretable(parse(source, 'exec').node)
481482
#print "got module", module
482483
if isinstance(frame, types.FrameType):
483-
frame = py.code.Frame(frame)
484+
frame = pytest.code.Frame(frame)
484485
try:
485486
module.run(frame)
486487
except Failure:
@@ -499,9 +500,9 @@ def interpret(source, frame, should_fail=False):
499500

500501
def getmsg(excinfo):
501502
if isinstance(excinfo, tuple):
502-
excinfo = py.code.ExceptionInfo(excinfo)
503+
excinfo = pytest.code.ExceptionInfo(excinfo)
503504
#frame, line = gettbline(tb)
504-
#frame = py.code.Frame(frame)
505+
#frame = pytest.code.Frame(frame)
505506
#return interpret(line, frame)
506507

507508
tb = excinfo.traceback[-1]
@@ -525,7 +526,7 @@ def getfailure(e):
525526
def run(s, frame=None):
526527
if frame is None:
527528
frame = sys._getframe(1)
528-
frame = py.code.Frame(frame)
529+
frame = pytest.code.Frame(frame)
529530
module = Interpretable(parse(s, 'exec').node)
530531
try:
531532
module.run(frame)

_pytest/assertion/reinterpret.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import sys
22
import py
3+
import pytest.code
34
from _pytest.assertion.util import BuiltinAssertionError
45
u = py.builtin._totext
56

@@ -22,7 +23,7 @@ def __init__(self, *args):
2223
"<[broken __repr__] %s at %0xd>"
2324
% (toprint.__class__, id(toprint)))
2425
else:
25-
f = py.code.Frame(sys._getframe(1))
26+
f = pytest.code.Frame(sys._getframe(1))
2627
try:
2728
source = f.code.fullsource
2829
if source is not None:

_pytest/assertion/util.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import pprint
33

44
import py
5+
import pytest.code
56
try:
67
from collections import Sequence
78
except ImportError:
@@ -170,7 +171,7 @@ def isiterable(obj):
170171
explanation = [
171172
u('(pytest_assertion plugin: representation of details failed. '
172173
'Probably an object has a faulty __repr__.)'),
173-
u(py.code.ExceptionInfo())]
174+
u(pytest.code.ExceptionInfo())]
174175

175176
if not explanation:
176177
return None

_pytest/code/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
""" python inspection/code generation API """

0 commit comments

Comments
 (0)