Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub tests are failing on Python 3.12 alpha 7 #569

Closed
cclauss opened this issue Apr 19, 2023 · 3 comments · Fixed by #568 or #570
Closed

GitHub tests are failing on Python 3.12 alpha 7 #569

cclauss opened this issue Apr 19, 2023 · 3 comments · Fixed by #568 or #570

Comments

@cclauss
Copy link
Contributor

cclauss commented Apr 19, 2023

See https://github.com/nose-devs/nose2/actions

@giampaolo
Copy link

giampaolo commented Apr 20, 2023

(__main__.Test.test) ... /opt/hostedtoolcache/Python/3.12.0-alpha.7/x64/lib/python3.12/unittest/case.py:580: RuntimeWarning: TestResult has no addDuration method\n  warnings.warn("TestResult has no addDuration method",\nok\n\n----------------------------------------------------------------------\nRan 1 test in 0.001s\n\nOK\n'

Seems related to: python/cpython#12271.

Without getting into deep analysys: the test seems to fail because unittest.TestCase class in python 3.12 has a new addDuration method. I imagine nose subclasses unittest.TestCase and extends it in some way. Python 3.12's unittest module is complaining (warning) that your custom sublcass does not provide an addDuration method. Defining an addDuration method will remove the warning and fix the failure.

@cclauss
Copy link
Contributor Author

cclauss commented Apr 20, 2023

https://github.com/python/cpython/pull/12271/files#diff-14c3c1d897d1e85767303f24626acaa6d1ea1162219c72caa240ef9f533ebe99R2176-R2181

   .. method:: addDuration(test, elapsed)

      Called when the test case finishes.  *elapsed* is the time represented in
      seconds, and it includes the execution of cleanup functions.

      .. versionadded:: 3.12

@sirosen
Copy link
Collaborator

sirosen commented Apr 25, 2023

My thanks to both of you for running this down and providing the breadcrumbs for me to understand what was happening. I've just merged @cclauss's fix and will make sure to cite him in the changelog under py3.12 compatibility.

chugcup added a commit to chugcup/nose that referenced this issue Mar 29, 2024
…ation' warning

The `unittest._TextTestResult` alias was removed in Python 3.12 in favor
of the `unittest.TextTestResult` class.  This class is overloaded in `result.py`
to implement some additional error classes and hooks.

Fixed by trying another import location, and using a local alias for the base class.
https://docs.python.org/3/whatsnew/3.12.html#id3

At invocation time, the test runner would also periodically emit warnings

    warnings.warn("TestResult has no addDuration method...

This appears to be a new Python 3.12 feature to track duration of tests for the
overall report, which isn't included in our subclass.  Added a stub to satisfy
this interface and silence the warnings.

https://docs.python.org/3/whatsnew/3.12.html#unittest
nose-devs/nose2#569

Bumped package version to '1.3.7.3'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants