Skip to content

Commit

Permalink
Fixed dummy runTest on functional test case.
Browse files Browse the repository at this point in the history
In functional doc tests you can apparently have a test case that has
no runTest method.  Until now the Testing package added a dummy
runTest method in that case, and set it to None.

The previous commit added a functional test case.  Somehow this caused
a problem in an unknown other functional test case because the dummy
runTest method got called:

  Error in test runTest (Testing.ZopeTestCase.ZopeTestCase.FunctionalTestCase)
  Traceback (most recent call last):
    File ".../lib/python2.7/unittest/case.py", line 329, in run
      testMethod()
  TypeError: 'NoneType' object is not callable

It was not even caused by anything in the new tests: simply importing
was enough to trigger it:

  from Testing.ZopeTestCase import FunctionalTestCase

So this has something to do with the order in which tests are found.

I fixed it by making the dummy runTest method callable.
  • Loading branch information
mauritsvanrees committed Jan 17, 2017
1 parent dba5f6c commit f18cf20
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Testing/ZopeTestCase/zopedoctest/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,9 @@ def setup_test_class(self):

# If the test_class does not have a runTest method, we add
# a dummy attribute so that TestCase construction works.
# runTest may get called, so set it to something that works.
if not hasattr(test_class, 'runTest'):
setattr(test_class, 'runTest', None)
setattr(test_class, 'runTest', lambda x: None)

# Create a TestCase instance which will be used to execute
# the setUp and tearDown methods, as well as be passed into
Expand Down Expand Up @@ -336,4 +337,3 @@ def FunctionalDocFileSuite(*paths, **kw):
'FunctionalDocTestSuite',
'FunctionalDocFileSuite',
]

0 comments on commit f18cf20

Please sign in to comment.