pyradius / pyrad

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

2.4 + master: pytest is failing #165

Closed kloczek closed 2 years ago

kloczek commented 2 years ago

I'm trying to package your module as an rpm package. So I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.

pytest without params is not able to find any units and only when I've passed tests/* as parameter it was ble to find units however some of them are failing. pytest shows as well some warnings. Here is pytest output:

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-pyrad-2.4-2.2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-pyrad-2.4-2.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.12, pytest-6.2.5, py-1.11.0, 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
============================================================================= warnings summary =============================================================================
tests/testBidict.py::BiDictTests::testItemAccessor
  /home/tkloczko/rpmbuild/BUILD/pyrad-2.4/tests/testBidict.py:55: DeprecationWarning: Please use assertEqual instead.
    self.assertEquals(self.bidict["shake"], "vanilla")

tests/testBidict.py::BiDictTests::testItemAccessor
  /home/tkloczko/rpmbuild/BUILD/pyrad-2.4/tests/testBidict.py:56: DeprecationWarning: Please use assertEqual instead.
    self.assertEquals(self.bidict["pie"], "custard")

tests/testClient.py::ConstructionTests::testNamedParameters
  /home/tkloczko/rpmbuild/BUILD/pyrad-2.4/tests/testClient.py:47: DeprecationWarning: Please use assertTrue instead.
    self.failUnless(client.server is self.server)

tests/testClient.py::ConstructionTests::testNamedParameters
  /home/tkloczko/rpmbuild/BUILD/pyrad-2.4/tests/testClient.py:51: DeprecationWarning: Please use assertTrue instead.
    self.failUnless(client.dict is marker)

tests/testClient.py::ConstructionTests::testParameterOrder
  /home/tkloczko/rpmbuild/BUILD/pyrad-2.4/tests/testClient.py:36: DeprecationWarning: Please use assertTrue instead.
    self.failUnless(client.server is self.server)

tests/testClient.py::ConstructionTests::testParameterOrder
  /home/tkloczko/rpmbuild/BUILD/pyrad-2.4/tests/testClient.py:41: DeprecationWarning: Please use assertTrue instead.
    self.failUnless(client.dict is marker)

tests/testClient.py::ConstructionTests::testSimpleConstruction
  /home/tkloczko/rpmbuild/BUILD/pyrad-2.4/tests/testClient.py:25: DeprecationWarning: Please use assertTrue instead.
    self.failUnless(client.server is self.server)

tests/testClient.py::ConstructionTests::testSimpleConstruction
  /home/tkloczko/rpmbuild/BUILD/pyrad-2.4/tests/testClient.py:31: DeprecationWarning: Please use assertTrue instead.
    self.failUnless(client.dict is None)

tests/testClient.py::SocketTests::testReopen
  /home/tkloczko/rpmbuild/BUILD/pyrad-2.4/tests/testClient.py:69: DeprecationWarning: Please use assertTrue instead.
    self.failUnless(sock is self.client._socket)

tests/testClient.py::SocketTests::testValidReply
  /home/tkloczko/rpmbuild/BUILD/pyrad-2.4/tests/testClient.py:157: DeprecationWarning: Please use assertTrue instead.
    self.failUnless(reply is packet.reply)

tests/testClient.py::OtherTests::testCreateAcctPacket
  /home/tkloczko/rpmbuild/BUILD/pyrad-2.4/tests/testClient.py:182: DeprecationWarning: Please use assertTrue instead.
    self.failUnless(isinstance(packet, AcctPacket))

tests/testClient.py::OtherTests::testCreateAcctPacket
  /home/tkloczko/rpmbuild/BUILD/pyrad-2.4/tests/testClient.py:183: DeprecationWarning: Please use assertTrue instead.
    self.failUnless(packet.dict is self.client.dict)

tests/testClient.py::OtherTests::testCreateAuthPacket
  /home/tkloczko/rpmbuild/BUILD/pyrad-2.4/tests/testClient.py:175: DeprecationWarning: Please use assertTrue instead.
    self.failUnless(isinstance(packet, AuthPacket))

tests/testClient.py::OtherTests::testCreateAuthPacket
  /home/tkloczko/rpmbuild/BUILD/pyrad-2.4/tests/testClient.py:176: DeprecationWarning: Please use assertTrue instead.
    self.failUnless(packet.dict is self.client.dict)

tests/testHost.py::PacketCreationTests::testCreateAcctPacket
  /home/tkloczko/rpmbuild/BUILD/pyrad-2.4/tests/testHost.py:47: DeprecationWarning: Please use assertTrue instead.
    self.failUnless(isinstance(packet, AcctPacket))

tests/testHost.py::PacketCreationTests::testCreateAcctPacket
  /home/tkloczko/rpmbuild/BUILD/pyrad-2.4/tests/testHost.py:48: DeprecationWarning: Please use assertTrue instead.
    self.failUnless(packet.dict is self.host.dict)

tests/testHost.py::PacketCreationTests::testCreateAuthPacket
  /home/tkloczko/rpmbuild/BUILD/pyrad-2.4/tests/testHost.py:41: DeprecationWarning: Please use assertTrue instead.
    self.failUnless(isinstance(packet, AuthPacket))

tests/testHost.py::PacketCreationTests::testCreateAuthPacket
  /home/tkloczko/rpmbuild/BUILD/pyrad-2.4/tests/testHost.py:42: DeprecationWarning: Please use assertTrue instead.
    self.failUnless(packet.dict is self.host.dict)

tests/testHost.py::PacketCreationTests::testCreatePacket
  /home/tkloczko/rpmbuild/BUILD/pyrad-2.4/tests/testHost.py:35: DeprecationWarning: Please use assertTrue instead.
    self.failUnless(isinstance(packet, Packet))

tests/testHost.py::PacketCreationTests::testCreatePacket
  /home/tkloczko/rpmbuild/BUILD/pyrad-2.4/tests/testHost.py:36: DeprecationWarning: Please use assertTrue instead.
    self.failUnless(packet.dict is self.host.dict)

tests/testHost.py::PacketSendTest::testSendPacket
  /home/tkloczko/rpmbuild/BUILD/pyrad-2.4/tests/testHost.py:81: DeprecationWarning: Please use assertTrue instead.
    self.failUnless(self.fd.data is self.packet.packet)

tests/testHost.py::PacketSendTest::testSendPacket
  /home/tkloczko/rpmbuild/BUILD/pyrad-2.4/tests/testHost.py:82: DeprecationWarning: Please use assertTrue instead.
    self.failUnless(self.fd.target is self.packet.source)

tests/testHost.py::PacketSendTest::testSendReplyPacket
  /home/tkloczko/rpmbuild/BUILD/pyrad-2.4/tests/testHost.py:86: DeprecationWarning: Please use assertTrue instead.
    self.failUnless(self.fd.data is self.packet.replypacket)

tests/testHost.py::PacketSendTest::testSendReplyPacket
  /home/tkloczko/rpmbuild/BUILD/pyrad-2.4/tests/testHost.py:87: DeprecationWarning: Please use assertTrue instead.
    self.failUnless(self.fd.target is self.packet.source)

tests/testProxy.py::SocketTests::testProxyFd
  /home/tkloczko/rpmbuild/BUILD/pyrad-2.4/tests/testProxy.py:33: DeprecationWarning: Please use assertTrue instead.
    self.failUnless(isinstance(self.proxy._proxyfd, MockSocket))

tests/testProxy.py::ProxyPacketHandlingTests::testHandleProxyPacketHandlesWrongPacket
  /home/tkloczko/rpmbuild/BUILD/pyrad-2.4/tests/testProxy.py:66: DeprecationWarning: Please use assertTrue instead.
    self.failUnless('non-response' in str(e))

tests/testProxy.py::ProxyPacketHandlingTests::testHandleProxyPacketUnknownHost
  /home/tkloczko/rpmbuild/BUILD/pyrad-2.4/tests/testProxy.py:53: DeprecationWarning: Please use assertTrue instead.
    self.failUnless('unknown host' in str(e))

tests/testServer.py::SocketTests::testGrabPacket
  /home/tkloczko/rpmbuild/BUILD/pyrad-2.4/tests/testServer.py:113: DeprecationWarning: Please use assertTrue instead.
    self.failUnless(isinstance(pkt, TrivialObject))

tests/testServer.py::SocketTests::testGrabPacket
  /home/tkloczko/rpmbuild/BUILD/pyrad-2.4/tests/testServer.py:114: DeprecationWarning: Please use assertTrue instead.
    self.failUnless(pkt.fd is fd)

tests/testServer.py::SocketTests::testGrabPacket
  /home/tkloczko/rpmbuild/BUILD/pyrad-2.4/tests/testServer.py:115: DeprecationWarning: Please use assertTrue instead.
    self.failUnless(pkt.source is fd.source)

tests/testServer.py::SocketTests::testGrabPacket
  /home/tkloczko/rpmbuild/BUILD/pyrad-2.4/tests/testServer.py:116: DeprecationWarning: Please use assertTrue instead.
    self.failUnless(pkt.data is fd.data)

tests/testServer.py::AuthPacketHandlingTests::testHandleAuthPacket
  /home/tkloczko/rpmbuild/BUILD/pyrad-2.4/tests/testServer.py:183: DeprecationWarning: Please use assertTrue instead.
    self.failUnless(self.server.handled is self.packet)

tests/testServer.py::AuthPacketHandlingTests::testHandleAuthPacketUnknownHost
  /home/tkloczko/rpmbuild/BUILD/pyrad-2.4/tests/testServer.py:163: DeprecationWarning: Please use assertTrue instead.
    self.failUnless('unknown host' in str(e))

tests/testServer.py::AuthPacketHandlingTests::testHandleAuthPacketWrongPort
  /home/tkloczko/rpmbuild/BUILD/pyrad-2.4/tests/testServer.py:172: DeprecationWarning: Please use assertTrue instead.
    self.failUnless('port' in str(e))

tests/testServer.py::AcctPacketHandlingTests::testHandleAcctPacket
  /home/tkloczko/rpmbuild/BUILD/pyrad-2.4/tests/testServer.py:222: DeprecationWarning: Please use assertTrue instead.
    self.failUnless(self.server.handled is self.packet)

tests/testServer.py::AcctPacketHandlingTests::testHandleAcctPacketUnknownHost
  /home/tkloczko/rpmbuild/BUILD/pyrad-2.4/tests/testServer.py:202: DeprecationWarning: Please use assertTrue instead.
    self.failUnless('unknown host' in str(e))

tests/testServer.py::AcctPacketHandlingTests::testHandleAcctPacketWrongPort
  /home/tkloczko/rpmbuild/BUILD/pyrad-2.4/tests/testServer.py:211: DeprecationWarning: Please use assertTrue instead.
    self.failUnless('port' in str(e))

tests/testServer.py::OtherTests::testCreateReplyPacket
  /home/tkloczko/rpmbuild/BUILD/pyrad-2.4/tests/testServer.py:245: DeprecationWarning: Please use assertTrue instead.
    self.failUnless(isinstance(reply, TrivialObject))

tests/testServer.py::OtherTests::testCreateReplyPacket
  /home/tkloczko/rpmbuild/BUILD/pyrad-2.4/tests/testServer.py:246: DeprecationWarning: Please use assertTrue instead.
    self.failUnless(reply.source is TrivialPacket.source)

tests/testServer.py::ServerRunTests::testRunInitializes
  /home/tkloczko/rpmbuild/BUILD/pyrad-2.4/tests/testServer.py:288: DeprecationWarning: Please use assertTrue instead.
    self.failUnless(isinstance(self.server._fdmap, dict))

tests/testServer.py::ServerRunTests::testRunInitializes
  /home/tkloczko/rpmbuild/BUILD/pyrad-2.4/tests/testServer.py:289: DeprecationWarning: Please use assertTrue instead.
    self.failUnless(isinstance(self.server._poll, MockPoll))

-- Docs: https://docs.pytest.org/en/stable/warnings.html
========================================================================= 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, 41 warnings in 2.70s ================================================================
tirkarthi commented 2 years ago

PR : https://github.com/pyradius/pyrad/pull/162