pyradius / pyrad

Python RADIUS Implementation
BSD 3-Clause "New" or "Revised" License
294 stars 186 forks source link

Refactor deprecated unittest aliases for Python 3.11 compatibility. #162

Closed tirkarthi closed 2 years ago

tirkarthi commented 3 years ago

The aliases were deprecated and removed in Python 3.11 . The recommended aliases are present in Python 2 too. Hence the PR is backwards compatible.

Ref : https://github.com/python/cpython/pull/28268

assertEquals -> assertEqual failIf -> assertFalse failUnless -> assertTrue

Fixes https://github.com/pyradius/pyrad/issues/165

kloczek commented 2 years ago

Just tested and pytest still is failing

warning: Downloading https://github.com/wichert/pyrad//archive/2.4/python-pyrad-2.4.tar.gz to /home/tkloczko/rpmbuild/SOURCES/python-pyrad-2.4.tar.gz
warning: Downloading https://github.com/wichert/pyrad//commit/36c38f19.patch#/python-pyrad-Create-python-test.yml.patch to /home/tkloczko/rpmbuild/SOURCES/python-pyrad-Create-python-test.yml.patch
warning: Downloading https://github.com/wichert/pyrad//commit/40b36c05.patch#/python-pyrad-Update-python-test.yml.patch to /home/tkloczko/rpmbuild/SOURCES/python-pyrad-Update-python-test.yml.patch
warning: Downloading https://github.com/wichert/pyrad//commit/51c9b0ca.patch#/python-pyrad-Update-README.rst.patch to /home/tkloczko/rpmbuild/SOURCES/python-pyrad-Update-README.rst.patch
warning: Downloading https://github.com/wichert/pyrad//commit/2591f66d.patch#/python-pyrad-Update-README.rst-2.patch to /home/tkloczko/rpmbuild/SOURCES/python-pyrad-Update-README.rst-2.patch
warning: Downloading https://github.com/wichert/pyrad//commit/ecfc8bcf.patch#/python-pyrad-update-readthedocs.patch to /home/tkloczko/rpmbuild/SOURCES/python-pyrad-update-readthedocs.patch
warning: Downloading https://github.com/wichert/pyrad//commit/724ed440.patch#/python-pyrad-Create-codeql-analysis.yml.patch to /home/tkloczko/rpmbuild/SOURCES/python-pyrad-Create-codeql-analysis.yml.patch
warning: Downloading https://github.com/wichert/pyrad//commit/488b7a0d.patch#/python-pyrad-Create-codacy-analysis.yml-2.patch to /home/tkloczko/rpmbuild/SOURCES/python-pyrad-Create-codacy-analysis.yml-2.patch
warning: Downloading https://github.com/wichert/pyrad//commit/ac814184.patch#/python-pyrad-Add-parsing-for-octets-coming-in-as-integer-or-str-v.patch to /home/tkloczko/rpmbuild/SOURCES/python-pyrad-Add-parsing-for-octets-coming-in-as-integer-or-str-v.patch
warning: Downloading https://github.com/wichert/pyrad//commit/1d5cd827.patch#/python-pyrad-Add-tests-for-bytes-string-integer-and-very-long-str.patch to /home/tkloczko/rpmbuild/SOURCES/python-pyrad-Add-tests-for-bytes-string-integer-and-very-long-str.patch
warning: Downloading https://github.com/wichert/pyrad//commit/ce9a6789.patch#/python-pyrad-Fix-152-and-add-tests-for-the-same.patch to /home/tkloczko/rpmbuild/SOURCES/python-pyrad-Fix-152-and-add-tests-for-the-same.patch
warning: Downloading https://github.com/wichert/pyrad//commit/e721d318.patch#/python-pyrad-Fix-documentation-for-bind-address.patch to /home/tkloczko/rpmbuild/SOURCES/python-pyrad-Fix-documentation-for-bind-address.patch
warning: Downloading https://github.com/wichert/pyrad//commit/1d638282.patch#/python-pyrad-fix-create-CoA-packet-in-client_async.patch to /home/tkloczko/rpmbuild/SOURCES/python-pyrad-fix-create-CoA-packet-in-client_async.patch
warning: Downloading https://github.com/wichert/pyrad//commit/990900d1.patch#/python-pyrad-Add-salt-decryption-of-encrypted-attributes.patch to /home/tkloczko/rpmbuild/SOURCES/python-pyrad-Add-salt-decryption-of-encrypted-attributes.patch
warning: Downloading https://github.com/wichert/pyrad//pull/162.patch#/python-pyrad-Refactor-deprecated-unittest-aliases-for-Python.patch to /home/tkloczko/rpmbuild/SOURCES/python-pyrad-Refactor-deprecated-unittest-aliases-for-Python.patch
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.tl8ek1
+ umask 022
+ cd /home/tkloczko/rpmbuild/BUILD
+ cd /home/tkloczko/rpmbuild/BUILD
+ rm -rf pyrad-2.4
+ /usr/bin/gzip -dc /home/tkloczko/rpmbuild/SOURCES/python-pyrad-2.4.tar.gz
+ /usr/bin/tar -xof -
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd pyrad-2.4
+ /usr/bin/chmod -Rf a+rX,u+w,g-w,o-w .
+ /usr/bin/cat /home/tkloczko/rpmbuild/SOURCES/python-pyrad-man3_level.patch
+ /usr/bin/patch -p1 -s --fuzz=0 --no-backup-if-mismatch -f
+ /usr/bin/cat /home/tkloczko/rpmbuild/SOURCES/python-pyrad-shebangs.patch
+ /usr/bin/patch -p1 -s --fuzz=0 --no-backup-if-mismatch -f
+ /usr/bin/cat /home/tkloczko/rpmbuild/SOURCES/python-pyrad-do_not_install_examples.patch
+ /usr/bin/patch -p1 -s --fuzz=0 --no-backup-if-mismatch -f
+ /usr/bin/cat /home/tkloczko/rpmbuild/SOURCES/python-pyrad-Create-python-test.yml.patch
+ /usr/bin/patch -p1 -s --fuzz=0 --no-backup-if-mismatch -f
+ /usr/bin/cat /home/tkloczko/rpmbuild/SOURCES/python-pyrad-Update-python-test.yml.patch
+ /usr/bin/patch -p1 -s --fuzz=0 --no-backup-if-mismatch -f
+ /usr/bin/cat /home/tkloczko/rpmbuild/SOURCES/python-pyrad-Update-README.rst.patch
+ /usr/bin/patch -p1 -s --fuzz=0 --no-backup-if-mismatch -f
+ /usr/bin/cat /home/tkloczko/rpmbuild/SOURCES/python-pyrad-Update-README.rst-2.patch
+ /usr/bin/patch -p1 -s --fuzz=0 --no-backup-if-mismatch -f
+ /usr/bin/cat /home/tkloczko/rpmbuild/SOURCES/python-pyrad-update-readthedocs.patch
+ /usr/bin/patch -p1 -s --fuzz=0 --no-backup-if-mismatch -f
+ /usr/bin/cat /home/tkloczko/rpmbuild/SOURCES/python-pyrad-Create-codeql-analysis.yml.patch
+ /usr/bin/patch -p1 -s --fuzz=0 --no-backup-if-mismatch -f
+ /usr/bin/cat /home/tkloczko/rpmbuild/SOURCES/python-pyrad-Create-codacy-analysis.yml-2.patch
+ /usr/bin/patch -p1 -s --fuzz=0 --no-backup-if-mismatch -f
+ /usr/bin/cat /home/tkloczko/rpmbuild/SOURCES/python-pyrad-Add-parsing-for-octets-coming-in-as-integer-or-str-v.patch
+ /usr/bin/patch -p1 -s --fuzz=0 --no-backup-if-mismatch -f
+ /usr/bin/cat /home/tkloczko/rpmbuild/SOURCES/python-pyrad-Add-tests-for-bytes-string-integer-and-very-long-str.patch
+ /usr/bin/patch -p1 -s --fuzz=0 --no-backup-if-mismatch -f
+ /usr/bin/cat /home/tkloczko/rpmbuild/SOURCES/python-pyrad-Fix-152-and-add-tests-for-the-same.patch
+ /usr/bin/patch -p1 -s --fuzz=0 --no-backup-if-mismatch -f
+ /usr/bin/cat /home/tkloczko/rpmbuild/SOURCES/python-pyrad-Fix-documentation-for-bind-address.patch
+ /usr/bin/patch -p1 -s --fuzz=0 --no-backup-if-mismatch -f
+ /usr/bin/cat /home/tkloczko/rpmbuild/SOURCES/python-pyrad-fix-create-CoA-packet-in-client_async.patch
+ /usr/bin/patch -p1 -s --fuzz=0 --no-backup-if-mismatch -f
+ /usr/bin/cat /home/tkloczko/rpmbuild/SOURCES/python-pyrad-Add-salt-decryption-of-encrypted-attributes.patch
+ /usr/bin/patch -p1 -s --fuzz=0 --no-backup-if-mismatch -f
+ /usr/bin/cat /home/tkloczko/rpmbuild/SOURCES/python-pyrad-Refactor-deprecated-unittest-aliases-for-Python.patch
+ /usr/bin/patch -p1 -s --fuzz=0 --no-backup-if-mismatch -f

[..]

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-pyrad-2.4-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-pyrad-2.4-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra tests/__init__.py tests/mock.py tests/testBidict.py tests/testClient.py tests/testDictionary.py tests/testHost.py tests/testPacket.py tests/testProxy.py tests/testServer.py tests/testTools.py
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.13, pytest-7.1.2, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/pyrad-2.4
collected 202 items

tests/testBidict.py .......                                                                                                                                          [  3%]
tests/testClient.py ...F..F......F....                                                                                                                               [ 12%]
tests/testDictionary.py .....................................                                                                                                        [ 30%]
tests/testHost.py ........                                                                                                                                           [ 34%]
tests/testPacket.py ................................................................................                                                                 [ 74%]
tests/testProxy.py ......                                                                                                                                            [ 77%]
tests/testServer.py .........................                                                                                                                        [ 89%]
tests/testTools.py .....................                                                                                                                             [100%]

================================================================================= FAILURES =================================================================================
________________________________________________________________________ SocketTests.testAuthDelay _________________________________________________________________________

self = <tests.testClient.SocketTests testMethod=testAuthDelay>

    def testAuthDelay(self):
        self.client.retries = 2
        self.client.timeout = 1
        packet = MockPacket(AccessRequest)
>       self.assertRaises(Timeout, self.client._SendPacket, packet, 432)

tests/testClient.py:125:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pyrad/client.py:159: in _SendPacket
    rawreply = self._socket.recv(4096)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    def recv(self, buffer):
>       return self.data[:buffer]
E       AttributeError: 'MockSocket' object has no attribute 'data'

tests/mock.py:62: AttributeError
____________________________________________________________________ SocketTests.testDoubleAccountDelay ____________________________________________________________________

self = <tests.testClient.SocketTests testMethod=testDoubleAccountDelay>

    def testDoubleAccountDelay(self):
        self.client.retries = 3
        self.client.timeout = 1
        packet = MockPacket(AccountingRequest)
>       self.assertRaises(Timeout, self.client._SendPacket, packet, 432)

tests/testClient.py:139:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pyrad/client.py:159: in _SendPacket
    rawreply = self._socket.recv(4096)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    def recv(self, buffer):
>       return self.data[:buffer]
E       AttributeError: 'MockSocket' object has no attribute 'data'

tests/mock.py:62: AttributeError
____________________________________________________________________ SocketTests.testSingleAccountDelay ____________________________________________________________________

self = <tests.testClient.SocketTests testMethod=testSingleAccountDelay>

    def testSingleAccountDelay(self):
        self.client.retries = 2
        self.client.timeout = 1
        packet = MockPacket(AccountingRequest)
>       self.assertRaises(Timeout, self.client._SendPacket, packet, 432)

tests/testClient.py:132:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pyrad/client.py:159: in _SendPacket
    rawreply = self._socket.recv(4096)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    def recv(self, buffer):
>       return self.data[:buffer]
E       AttributeError: 'MockSocket' object has no attribute 'data'

tests/mock.py:62: AttributeError
========================================================================= short test summary info ==========================================================================
FAILED tests/testClient.py::SocketTests::testAuthDelay - AttributeError: 'MockSocket' object has no attribute 'data'
FAILED tests/testClient.py::SocketTests::testDoubleAccountDelay - AttributeError: 'MockSocket' object has no attribute 'data'
FAILED tests/testClient.py::SocketTests::testSingleAccountDelay - AttributeError: 'MockSocket' object has no attribute 'data'
====================================================================== 3 failed, 199 passed in 2.49s =======================================================================
kloczek commented 2 years ago

list of modules installed in build env

Package                       Version
----------------------------- -----------------
alabaster                     0.7.12
attrs                         22.1.0.dev0
Babel                         2.10.2
Brlapi                        0.8.3
build                         0.8.0
CacheControl                  0.12.10
cachy                         0.3.0
cffi                          1.15.0
charset-normalizer            2.1.0
cleo                          0.8.1
clikit                        0.6.2
codespell                     2.1.0
crashtest                     0.3.1
cryptography                  36.0.2
cycler                        0.11.0
distlib                       0.3.4
distro                        1.7.0
docutils                      0.17.1
extended-project              1.2.3
extras                        1.0.0
filelock                      3.7.1
fixtures                      4.0.0
fonttools                     4.34.4
gpg                           1.17.1-unknown
html5lib                      1.1
idna                          3.3
imagesize                     1.4.1
importlib-metadata            4.12.0
iniconfig                     1.1.1
jeepney                       0.8.0
Jinja2                        3.1.1
keyring                       23.6.0
kiwisolver                    1.4.3
libcomps                      0.1.18
lockfile                      0.12.2
louis                         3.22.0
MarkupSafe                    2.1.1
matplotlib                    3.5.2
msgpack                       1.0.4
netaddr                       0.8.0
numpy                         1.23.1
olefile                       0.46
packaging                     21.3
pastel                        0.2.1
pbr                           5.8.1
pep517                        0.12.0
pexpect                       4.8.0
Pillow                        9.2.0
pip                           22.0.4
pkginfo                       1.8.3
platformdirs                  2.5.2
pluggy                        1.0.0
ply                           3.11
poetry                        1.1.14
poetry-core                   1.0.8
ptyprocess                    0.7.0
py                            1.11.0
pycparser                     2.21
Pygments                      2.12.0
PyGObject                     3.42.1
pylev                         1.4.0
pyparsing                     3.0.9
pytest                        7.1.2
python-dateutil               2.8.2
pytz                          2022.1
requests                      2.28.1
requests-toolbelt             0.9.1
rpm                           4.17.0
SecretStorage                 3.3.1
setuptools                    63.1.0
shellingham                   1.4.0
simple-project                1.2.3
six                           1.16.0
snowballstemmer               2.2.0
Sphinx                        5.0.2
sphinxcontrib-applehelp       1.0.2.dev20220410
sphinxcontrib-devhelp         1.0.2.dev20220410
sphinxcontrib-htmlhelp        2.0.0
sphinxcontrib-jsmath          1.0.1.dev20220712
sphinxcontrib-qthelp          1.0.3.dev20220712
sphinxcontrib-serializinghtml 1.1.5
testtools                     2.5.0
tomli                         2.0.1
tomlkit                       0.11.1
urllib3                       1.26.9
virtualenv                    20.15.1
webencodings                  0.5.1
wheel                         0.37.1
zipp                          3.8.0