[py-svn] commit/pytest: gutworth: fix the rewriter on relative imports (fixes #58)
Bitbucket
commits-noreply at bitbucket.org
Tue Jun 28 17:39:08 CEST 2011
1 new changeset in pytest:
http://bitbucket.org/hpk42/pytest/changeset/ad2f1532c8b8/
changeset: ad2f1532c8b8
user: gutworth
date: 2011-06-28 17:39:11
summary: fix the rewriter on relative imports (fixes #58)
affected #: 2 files (282 bytes)
--- a/_pytest/assertion/rewrite.py Mon Jun 20 18:12:48 2011 +0200
+++ b/_pytest/assertion/rewrite.py Tue Jun 28 10:39:11 2011 -0500
@@ -109,8 +109,8 @@
return
lineno += len(doc) - 1
expect_docstring = False
- elif (not isinstance(item, ast.ImportFrom) or item.level > 0 and
- item.identifier != "__future__"):
+ elif (not isinstance(item, ast.ImportFrom) or item.level > 0 or
+ item.module != "__future__"):
lineno = item.lineno
break
pos += 1
--- a/testing/test_assertrewrite.py Mon Jun 20 18:12:48 2011 +0200
+++ b/testing/test_assertrewrite.py Tue Jun 28 10:39:11 2011 -0500
@@ -76,6 +76,13 @@
assert imp.lineno == 3
assert imp.col_offset == 0
assert isinstance(m.body[4], ast.Expr)
+ s = """from . import relative\nother_stuff"""
+ m = rewrite(s)
+ for imp in m.body[0:2]:
+ assert isinstance(imp, ast.Import)
+ assert imp.lineno == 1
+ assert imp.col_offset == 0
+ assert isinstance(m.body[3], ast.Expr)
def test_dont_rewrite(self):
s = """'PYTEST_DONT_REWRITE'\nassert 14"""
Repository URL: https://bitbucket.org/hpk42/pytest/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the pytest-commit
mailing list