diff --git a/CHANGELOG b/CHANGELOG index 6b7bd10b0..0d66e8765 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -12,6 +12,8 @@ Changes between 2.2.0 and 2.2.1.dev the good reporting and feedback. The pytest_runtest_protocol as well as the pytest_runtest_teardown hooks now have "nextitem" available which will be None indicating the end of the test run. +- fix collection crash due to unknown-source collected items, thanks + to Ralf Schmitt (fixed by depending on a more recent pylib) Changes between 2.1.3 and 2.2.0 ---------------------------------------- diff --git a/_pytest/__init__.py b/_pytest/__init__.py index 260d50188..70d91393b 100644 --- a/_pytest/__init__.py +++ b/_pytest/__init__.py @@ -1,2 +1,2 @@ # -__version__ = '2.2.1.dev4' +__version__ = '2.2.1.dev5' diff --git a/_pytest/python.py b/_pytest/python.py index 61fea05e4..0dab4b10e 100644 --- a/_pytest/python.py +++ b/_pytest/python.py @@ -156,6 +156,7 @@ class PyobjMixin(object): obj = obj.place_as self._fslineno = py.code.getfslineno(obj) + assert isinstance(self._fslineno[1], int), obj return self._fslineno def reportinfo(self): @@ -173,6 +174,7 @@ class PyobjMixin(object): else: fspath, lineno = self._getfslineno() modpath = self.getmodpath() + assert isinstance(lineno, int) return fspath, lineno, modpath class PyCollectorMixin(PyobjMixin, pytest.Collector): diff --git a/setup.py b/setup.py index 2a31ab2e4..10f39e7bb 100644 --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ def main(): name='pytest', description='py.test: simple powerful testing with Python', long_description = long_description, - version='2.2.1.dev4', + version='2.2.1.dev5', url='http://pytest.org', license='MIT license', platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'], @@ -32,7 +32,7 @@ def main(): author_email='holger at merlinux.eu', entry_points= make_entry_points(), # the following should be enabled for release - install_requires=['py>=1.4.6.dev5'], + install_requires=['py>=1.4.6.dev6'], classifiers=['Development Status :: 6 - Mature', 'Intended Audience :: Developers', 'License :: OSI Approved :: MIT License', @@ -70,4 +70,4 @@ def make_entry_points(): return {'console_scripts': l} if __name__ == '__main__': - main() + main() \ No newline at end of file diff --git a/testing/test_python.py b/testing/test_python.py index c59803334..526ecc974 100644 --- a/testing/test_python.py +++ b/testing/test_python.py @@ -1517,3 +1517,20 @@ def test_customize_through_attributes(testdir): "*MyInstance*", "*MyFunction*test_hello*", ]) + + +def test_unorderable_types(testdir): + testdir.makepyfile(""" + class TestJoinEmpty: + pass + + def make_test(): + class Test: + pass + Test.__name__ = "TestFoo" + return Test + TestFoo = make_test() + """) + result = testdir.runpytest() + assert "TypeError" not in result.stdout.str() + assert result.ret == 0 diff --git a/testing/test_unittest.py b/testing/test_unittest.py index 738408f96..2abf8b49d 100644 --- a/testing/test_unittest.py +++ b/testing/test_unittest.py @@ -38,7 +38,7 @@ def test_setup(testdir): assert self.foo2 == 1 def teardown_method(self, method): assert 0, "42" - + """) reprec = testdir.inline_run("-s", testpath) assert reprec.matchreport("test_both", when="call").passed @@ -431,3 +431,20 @@ def test_unittest_not_shown_in_traceback(testdir): """) res = testdir.runpytest() assert "failUnlessEqual" not in res.stdout.str() + +def test_unorderable_types(testdir): + testdir.makepyfile(""" + import unittest + class TestJoinEmpty(unittest.TestCase): + pass + + def make_test(): + class Test(unittest.TestCase): + pass + Test.__name__ = "TestFoo" + return Test + TestFoo = make_test() + """) + result = testdir.runpytest() + assert "TypeError" not in result.stdout.str() + assert result.ret == 0 diff --git a/tox.ini b/tox.ini index bd927820d..162674b1c 100644 --- a/tox.ini +++ b/tox.ini @@ -4,7 +4,7 @@ envlist=py26,py27,py31,py32,py27-xdist,py25,py24 indexserver= pypi = http://pypi.python.org/simple testrun = http://pypi.testrun.org - default = http://pypi.testrun.org +# default = http://pypi.testrun.org [testenv] changedir=testing @@ -50,8 +50,12 @@ deps=:pypi:sphinx commands= make html +;;[testenv:py31] +;;deps=:pypi:nose>=1.0 + [testenv:py31] -deps=:pypi:nose>=1.0 +deps= + {distshare}/py-1.4.6* [testenv:py31-xdist] deps=pytest-xdist