Fix tests for Python 3.11 using teyit

Open
#1 · Created  · Last updated

Description

assertEquals was deprecated in Python 3.2 and is removed in Python 3.11. Use assertEqual instead.

 

I used https://github.com/isidentical/teyit to update, and it also upgraded this for better error messages:

- self.assertTrue('Some unicode string' in logfile_handle.read()) + self.assertIn('Some unicode string', logfile_handle.read())

 

Before:

 

$ tox -e py311 GLOB sdist-make: /private/tmp/logutils/setup.py py311 inst-nodeps: /private/tmp/logutils/.tox/.tmp/package/1/logutils-0.3.6.zip py311 installed: logutils @ file:///private/tmp/logutils/.tox/.tmp/package/1/logutils-0.3.6.zip py311 run-test-pre: PYTHONHASHSEED='1823791550' py311 run-test: commands[0] | python setup.py test /private/tmp/logutils/setup.py:3: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives import distutils.core running test ....Some unicode string with some śćźół chars .s......EE.................. ====================================================================== ERROR: test_config4_ok (test_dictconfig.ConfigDictTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "/private/tmp/logutils/tests/test_dictconfig.py", line 571, in test_config4_ok self.assertEquals(h.formatted[0], ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'ConfigDictTest' object has no attribute 'assertEquals' ====================================================================== ERROR: test_config4a_ok (test_dictconfig.ConfigDictTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "/private/tmp/logutils/tests/test_dictconfig.py", line 583, in test_config4a_ok self.assertEquals(h.formatted[0], ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'ConfigDictTest' object has no attribute 'assertEquals' ---------------------------------------------------------------------- Ran 32 tests in 0.015s FAILED (errors=2, skipped=1) ERROR: InvocationError for command /private/tmp/logutils/.tox/py311/bin/python setup.py test (exited with code 1) _________________________________________________________________ summary _________________________________________________________________ ERROR: py311: commands failed

 

After:

 

$ tox -e py311 GLOB sdist-make: /private/tmp/logutils/setup.py py311 inst-nodeps: /private/tmp/logutils/.tox/.tmp/package/1/logutils-0.3.6.zip py311 installed: logutils @ file:///private/tmp/logutils/.tox/.tmp/package/1/logutils-0.3.6.zip py311 run-test-pre: PYTHONHASHSEED='3198781280' py311 run-test: commands[0] | python setup.py test /private/tmp/logutils/setup.py:3: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives import distutils.core running test ....Some unicode string with some śćźół chars .s.......................... ---------------------------------------------------------------------- Ran 32 tests in 0.014s OK (skipped=1) _________________________________________________________________ summary _________________________________________________________________ py311: commands succeeded congratulations :)

 

 

0 attachments

0 comments

Loading commits...