plone / plone.api

The Plone API
https://6.docs.plone.org/plone.api
Other
88 stars 53 forks source link

Doctests are empty on Python 2 and give error in zope.testrunner #454

Open mauritsvanrees opened 3 years ago

mauritsvanrees commented 3 years ago

With tox (from a branch):

Running plone.api.tests.base.PloneApiLayer:Integration tests:
  Set up plone.testing.zca.LayerCleanup in 0.000 seconds.
  Set up plone.testing.zope.Startup in 0.259 seconds.
  Set up plone.app.testing.layers.PloneFixture in 7.383 seconds.
  Set up plone.api.tests.base.PloneApiLayer in 2.327 seconds.
  Set up plone.api.tests.base.PloneApiLayer:Integration in 0.000 seconds.
  Running:

  Ran 214 tests with 0 failures, 0 errors and 3 skipped in 34.996 seconds.
Running plone.app.testing.layers.Plone:Integration tests:
  Tear down plone.api.tests.base.PloneApiLayer:Integration in 0.000 seconds.
  Tear down plone.api.tests.base.PloneApiLayer in 0.007 seconds.
  Set up plone.app.testing.layers.Plone:Integration in 0.000 seconds.
  Running:
Traceback (most recent call last):                                             
  File ".tox/py27-plone-5.2/bin/test", line 281, in <module>
    '--test-path', '/Users/maurits/community/plone-coredev/py3/src/plone.api/src',
  File "/Users/maurits/shared-eggs/cp27m/zope.testrunner-5.2-py2.7.egg/zope/testrunner/__init__.py", line 31, in run
    warnings=warnings)
  File "/Users/maurits/shared-eggs/cp27m/zope.testrunner-5.2-py2.7.egg/zope/testrunner/__init__.py", line 51, in run_internal
    runner.run()
  File "/Users/maurits/shared-eggs/cp27m/zope.testrunner-5.2-py2.7.egg/zope/testrunner/runner.py", line 191, in run
    self.run_tests()
  File "/Users/maurits/shared-eggs/cp27m/zope.testrunner-5.2-py2.7.egg/zope/testrunner/runner.py", line 293, in run_tests
    self.skipped, self.import_errors)
  File "/Users/maurits/shared-eggs/cp27m/zope.testrunner-5.2-py2.7.egg/zope/testrunner/runner.py", line 474, in run_layer
    import_errors)
  File "/Users/maurits/shared-eggs/cp27m/zope.testrunner-5.2-py2.7.egg/zope/testrunner/runner.py", line 396, in run_tests
    test(result)
  File "/Users/maurits/.pyenv/versions/2.7.17/lib/python2.7/unittest/case.py", line 393, in __call__
    return self.run(*args, **kwds)
  File "/Users/maurits/.pyenv/versions/2.7.17/lib/python2.7/unittest/case.py", line 304, in run
    result.startTest(self)
  File "/Users/maurits/shared-eggs/cp27m/zope.testrunner-5.2-py2.7.egg/zope/testrunner/runner.py", line 927, in startTest
    self.options.output.start_test(test, self.testsRun, self.count)
  File "/Users/maurits/shared-eggs/cp27m/zope.testrunner-5.2-py2.7.egg/zope/testrunner/formatter.py", line 276, in start_test
    tests_run * 100.0 / total_tests)
ZeroDivisionError: float division by zero

Partially this is an error in zope.testrunner. It is trying to print something like zero tests run out of zero total and then tries to give a percentage, which fails.

But the problem for plone.api is that not all tests are run. When I run all tests, Python 2 runs 214 and Python 3 run 401 tests. There may be some differences because some tests are skipped on one or the other, but not this much.

When I dive in, I see this is because the doctests are not recognised. On coredev 5.2 Python 2 you get the same error with this:

$ bin/test -s plone.api -t group.rst

or:

$ bin/test -s plone.api -m test_doctests

With Python 3, this happily runs 39 tests.

This was not noticed until now because of two things:

  1. plone.api tests on Jenkins for some reason do not give the error traceback from zope.testrunner.
  2. plone.api has Travis tests, but only for Plone 4.3-5.1. This is being fixed in PR #431 and #453.

Main question: does anyone understand why the doctests are not run on Py 2? There are no >>> markings for the tests, but when I try that, it does not help.