Commits

holger krekel committed abdcfe8

fix issue17 (of the pytest tracker): import-* statements could be processed wrong on python3 because they are disallowed in functions (which were temporarily created)

  • Participants
  • Parent commits 9265aa1

Comments (0)

Files changed (7)

+Changes between 1.4.0 and 1.4.1
+==================================================
+
+- fix (pytest-) issue17 where python3 does not like "import *"
+  leading to misrepresentation of import-errors in test modules
 
 Changes between 1.3.4 and 1.4.0
 ==================================================
 
 (c) Holger Krekel and others, 2004-2010
 """
-__version__ = '1.4.0'
+__version__ = '1.4.1.dev1'
 
 from py import _apipkg
 

py/_code/source.py

                     continue
             trylines = self.lines[start:lineno+1]
             # quick hack to indent the source and get it as a string in one go
-            trylines.insert(0, 'def xxx():')
+            trylines.insert(0, 'if xxx:')
             trysource = '\n '.join(trylines)
             #              ^ space here
             try:
         name='py',
         description='library with cross-python path, ini-parsing, io, code, log facilities',
         long_description = open('README.txt').read(),
-        version='1.4.0',
+        version='1.4.1.dev1',
         url='http://pylib.org',
         license='MIT license',
         platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],

testing/code/__init__.py

-#

testing/code/test_source.py

         assert len(source) == 9
         assert source.getstatementrange(5) == (0, 9)
 
+    def test_getstatementrange_out_of_bounds_py3(self):
+        source = Source("if xxx:\n   from .collections import *")
+        r = source.getstatementrange(1)
+        assert r == (1,2)
+
     @py.test.mark.skipif("sys.version_info < (2,6)")
     def test_compile_to_ast(self):
         import ast
     _, A_lineno = py.std.inspect.findsource(A)
     assert fspath.basename == "test_source.py"
     assert lineno == A_lineno
+
 [tox]
-envlist=py26,py27,py31,py27-xdist,py25,py24
+envlist=py26,py27,py31,py32,py27-xdist,py25,py24
 indexserver=
     default=http://pypi.testrun.org
 
 [testenv]
 changedir=testing
 commands=py.test -rfsxX --junitxml={envlogdir}/junit-{envname}.xml []
-deps=pytest>=2.0.0.dev34
+deps=pytest>=2.0.0
 
 [testenv:py27-xdist]
 basepython=python2.7