Commits

holger krekel committed 51640a2

fix unorderable types as reported by Ralf Schmitt

Comments (0)

Files changed (7)

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

_pytest/__init__.py

 #
-__version__ = '2.2.1.dev4'
+__version__ = '2.2.1.dev5'

_pytest/python.py

             obj = obj.place_as
 
         self._fslineno = py.code.getfslineno(obj)
+        assert isinstance(self._fslineno[1], int), obj
         return self._fslineno
 
     def reportinfo(self):
         else:
             fspath, lineno = self._getfslineno()
             modpath = self.getmodpath()
+        assert isinstance(lineno, int)
         return fspath, lineno, modpath
 
 class PyCollectorMixin(PyobjMixin, pytest.Collector):
         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'],
         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',
     return {'console_scripts': l}
 
 if __name__ == '__main__':
-    main()
+    main()

testing/test_python.py

         "*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

testing/test_unittest.py

                 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
     """)
     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
 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
 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