fix unorderable types as reported by Ralf Schmitt

This commit is contained in:
holger krekel 2011-12-14 10:56:51 +00:00
parent 94e31e414a
commit 82ba764bb6
7 changed files with 49 additions and 7 deletions

View File

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

View File

@ -1,2 +1,2 @@
#
__version__ = '2.2.1.dev4'
__version__ = '2.2.1.dev5'

View File

@ -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):

View File

@ -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()

View File

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

View File

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

View File

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