epics-base / ci-scripts

Continuous Integration Scripts for EPICS Modules
Other
8 stars 18 forks source link

unittest changes in Python 3.11 break self-test #88

Closed ralphlange closed 1 year ago

ralphlange commented 1 year ago

Newer Windows build starts seeing:

======================================================================
ERROR: test_MisspelledConfigurationGetsWarning (__main__.TestAppveyorDetectContext.test_MisspelledConfigurationGetsWarning)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\projects\ci-scripts\cue-test.py", line 701, in test_MisspelledConfigurationGetsWarning
    self.assertRegexpMatches(capturedOutput.getvalue(), "Unrecognized build configuration setting")
    ^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'TestAppveyorDetectContext' object has no attribute 'assertRegexpMatches'
======================================================================
ERROR: test_StaticGetsWarning (__main__.TestAppveyorDetectContext.test_StaticGetsWarning)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\projects\ci-scripts\cue-test.py", line 693, in test_StaticGetsWarning
    self.assertRegexpMatches(capturedOutput.getvalue(), "Variable 'STATIC' not supported anymore")
    ^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'TestAppveyorDetectContext' object has no attribute 'assertRegexpMatches'
======================================================================
ERROR: test_DoubleIncludeGetsIgnored (__main__.TestSourceSet.test_DoubleIncludeGetsIgnored)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\projects\ci-scripts\cue-test.py", line 123, in test_DoubleIncludeGetsIgnored
    self.assertRegexpMatches(capturedOutput.getvalue(), 'Ignoring already included setup file')
    ^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'TestSourceSet' object has no attribute 'assertRegexpMatches'
======================================================================
ERROR: test_EmptySetupDirsPath (__main__.TestSourceSet.test_EmptySetupDirsPath)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\projects\ci-scripts\cue-test.py", line 83, in test_EmptySetupDirsPath
    self.assertRaisesRegexp(NameError, '\(SETUP_PATH\) is empty', cue.source_set, 'test01')
    ^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'TestSourceSet' object has no attribute 'assertRaisesRegexp'. Did you mean: 'assertRaisesRegex'?
======================================================================
ERROR: test_InvalidSetupName (__main__.TestSourceSet.test_InvalidSetupName)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\projects\ci-scripts\cue-test.py", line 86, in test_InvalidSetupName
    self.assertRaisesRegexp(NameError, 'does not exist in SETUP_PATH', cue.source_set, 'xxdoesnotexistxx')
    ^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'TestSourceSet' object has no attribute 'assertRaisesRegexp'. Did you mean: 'assertRaisesRegex'?

A bug in RedHat Bugzilla (https://bugzilla.redhat.com/show_bug.cgi?id=2019006) suggests:

In Python 3.11 many old deprecated unittest features are removed:

    TestCase method aliases failUnlessEqual, failIfEqual, failUnless, failIf, failUnlessRaises, failUnlessAlmostEqual, failIfAlmostEqual (deprecated in Python 3.1), assertEquals, assertNotEquals, assert_, assertAlmostEquals, assertNotAlmostEquals, assertRegexpMatches, assertRaisesRegexp (deprecated in Python 3.2), and assertNotRegexpMatches (deprecated in Python 3.5).

    Undocumented and broken TestCase method assertDictContainsSubset (deprecated in Python 3.2).

    Undocumented <unittest.TestLoader.loadTestsFromModule> TestLoader.loadTestsFromModule() parameter use_load_tests (deprecated and ignored since Python 3.2).

    An alias of the TextTestResult class: _TextTestResult (deprecated in Python 3.2).

(Contributed by Serhiy Storchaka in bpo-45162.)

https://docs.python.org/3.11/whatsnew/3.11.html