-
Notifications
You must be signed in to change notification settings - Fork 43
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
test failure (python3 related?) #45
Comments
@colemickens, the unit tests on the |
The ============================= test session starts ==============================
platform linux -- Python 3.8.9, pytest-6.2.3, py-1.10.0, pluggy-0.13.1
rootdir: /build/source
collected 70 items
test/test_ad2.py .............................. [ 42%]
test/test_devices.py .................FF.. [ 72%]
test/test_messages.py .......... [ 87%]
test/test_zonetracking.py ......... [100%]
=================================== FAILURES ===================================
__________________________ TestSocketDevice.test_ssl ___________________________
self = <test.test_devices.TestSocketDevice testMethod=test_ssl>
def test_ssl(self):
if not have_openssl:
return
ssl_key = crypto.PKey()
ssl_key.generate_key(crypto.TYPE_RSA, 2048)
ssl_cert = crypto.X509()
ssl_cert.set_pubkey(ssl_key)
ssl_ca_key = crypto.PKey()
ssl_ca_key.generate_key(crypto.TYPE_RSA, 2048)
ssl_ca_cert = crypto.X509()
ssl_ca_cert.set_pubkey(ssl_ca_key)
self._device.ssl = True
self._device.ssl_key = ssl_key
self._device.ssl_certificate = ssl_cert
self._device.ssl_ca = ssl_ca_cert
fileno, path = tempfile.mkstemp()
# ..there has to be a better way..
with patch.object(socket.socket, '__init__', return_value=None):
with patch.object(socket.socket, 'connect', return_value=None) as mock:
> with patch.object(socket.socket, '_sock'):
test/test_devices.py:254:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/nix/store/r9h3422p0jmajpihwhya7vxdz0z29dyv-python3.8-mock-4.0.3/lib/python3.8/site-packages/mock/mock.py:1414: in __enter__
original, local = self.get_original()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <mock.mock._patch object at 0x7ffff4dac340>
def get_original(self):
target = self.getter()
name = self.attribute
original = DEFAULT
local = False
try:
original = target.__dict__[name]
except (AttributeError, KeyError):
original = getattr(target, name, DEFAULT)
else:
local = True
if name in _builtins and isinstance(target, ModuleType):
self.create = True
if not self.create and original is DEFAULT:
> raise AttributeError(
"%s does not have the attribute %r" % (target, name)
)
E AttributeError: <class 'socket.socket'> does not have the attribute '_sock'
/nix/store/r9h3422p0jmajpihwhya7vxdz0z29dyv-python3.8-mock-4.0.3/lib/python3.8/site-packages/mock/mock.py:1387: AttributeError
_____________________ TestSocketDevice.test_ssl_exception ______________________
self = <test.test_devices.TestSocketDevice testMethod=test_ssl_exception>
def test_ssl_exception(self):
if not have_openssl:
return
self._device.ssl = True
self._device.ssl_key = 'None'
self._device.ssl_certificate = 'None'
self._device.ssl_ca = 'None'
fileno, path = tempfile.mkstemp()
# ..there has to be a better way..
with patch.object(socket.socket, '__init__', return_value=None):
with patch.object(socket.socket, 'connect', return_value=None) as mock:
> with patch.object(socket.socket, '_sock'):
test/test_devices.py:281:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/nix/store/r9h3422p0jmajpihwhya7vxdz0z29dyv-python3.8-mock-4.0.3/lib/python3.8/site-packages/mock/mock.py:1414: in __enter__
original, local = self.get_original()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <mock.mock._patch object at 0x7ffff50c2520>
def get_original(self):
target = self.getter()
name = self.attribute
original = DEFAULT
local = False
try:
original = target.__dict__[name]
except (AttributeError, KeyError):
original = getattr(target, name, DEFAULT)
else:
local = True
if name in _builtins and isinstance(target, ModuleType):
self.create = True
if not self.create and original is DEFAULT:
> raise AttributeError(
"%s does not have the attribute %r" % (target, name)
)
E AttributeError: <class 'socket.socket'> does not have the attribute '_sock'
/nix/store/r9h3422p0jmajpihwhya7vxdz0z29dyv-python3.8-mock-4.0.3/lib/python3.8/site-packages/mock/mock.py:1387: AttributeError
=============================== warnings summary ===============================
[...]
-- Docs: https://docs.pytest.org/en/stable/warnings.html
=========================== short test summary info ============================
FAILED test/test_devices.py::TestSocketDevice::test_ssl - AttributeError: <cl...
FAILED test/test_devices.py::TestSocketDevice::test_ssl_exception - Attribute...
================== 2 failed, 68 passed, 23 warnings in 2.13s =================== |
okay, I will try to take a look at this soon. |
@fabaff, I'm not familiar with NixOS. are there any docs that you can point me to that describe how I can run these tests in the same environment? I'm having trouble replicating the issue in my local environment using Python 3.8.9 |
The nixpkgs manual has a Python section. There is a small subsection called "Testing Python Packages". I though that the issue could be that I was running the tests with running install tests
...............................................EE.....................
======================================================================
ERROR: test_ssl (test.test_devices.TestSocketDevice)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/build/source/test/test_devices.py", line 254, in test_ssl
with patch.object(socket.socket, '_sock'):
File "/nix/store/r9h3422p0jmajpihwhya7vxdz0z29dyv-python3.8-mock-4.0.3/lib/python3.8/site-packages/mock/mock.py", line 1414, in __enter__
original, local = self.get_original()
File "/nix/store/r9h3422p0jmajpihwhya7vxdz0z29dyv-python3.8-mock-4.0.3/lib/python3.8/site-packages/mock/mock.py", line 1387, in get_original
raise AttributeError(
AttributeError: <class 'socket.socket'> does not have the attribute '_sock'
======================================================================
ERROR: test_ssl_exception (test.test_devices.TestSocketDevice)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/build/source/test/test_devices.py", line 281, in test_ssl_exception
with patch.object(socket.socket, '_sock'):
File "/nix/store/r9h3422p0jmajpihwhya7vxdz0z29dyv-python3.8-mock-4.0.3/lib/python3.8/site-packages/mock/mock.py", line 1414, in __enter__
original, local = self.get_original()
File "/nix/store/r9h3422p0jmajpihwhya7vxdz0z29dyv-python3.8-mock-4.0.3/lib/python3.8/site-packages/mock/mock.py", line 1387, in get_original
raise AttributeError(
AttributeError: <class 'socket.socket'> does not have the attribute '_sock'
----------------------------------------------------------------------
Ran 70 tests in 0.453s
FAILED (errors=2) If it's Python 3.8 or Python 3.9 doesn't matter ;-) The tests are passing on Fedora 34. No difference between [fabaff@ch ~]$ git clone [email protected]:nutechsoftware/alarmdecoder.git
[fabaff@ch ~]$ cd alarmdecoder/
[fabaff@ch alarmdecoder]$ python -m venv .
[fabaff@ch alarmdecoder]$ source bin/activate
(alarmdecoder) [fabaff@ch alarmdecoder]$ pip3 install -r requirements.txt
(alarmdecoder) [fabaff@ch alarmdecoder]$ pip3 install nose mock
(alarmdecoder) [fabaff@ch alarmdecoder]$ nosetests
......................................................................
----------------------------------------------------------------------
Ran 70 tests in 0.326s
OK
(alarmdecoder) [fabaff@ch alarmdecoder]$ pip3 install pytest
[...]
You should consider upgrading via the '/home/fab/alarmdecoder/bin/python -m pip install --upgrade pip' command.
(alarmdecoder) [fabaff@ch alarmdecoder]$ pytest
============================================================================================= test session starts ==============================================================================================
platform linux -- Python 3.9.5, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
rootdir: /home/fab/alarmdecoder
collected 70 items
test/test_ad2.py .............................. [ 42%]
test/test_devices.py ..................... [ 72%]
test/test_messages.py .......... [ 87%]
test/test_zonetracking.py ......... [100%]
=============================================================================================== warnings summary ===============================================================================================
test/test_ad2.py::TestAlarmDecoder::test_config_message
[...]
======================================================================================= 70 passed, 20 warnings in 1.39s ======================================================================================== I don't see major version deviations of the pulled-in Python modules. |
I'm getting some test failures while trying to package this for NixOS.
Any suggestions?
The text was updated successfully, but these errors were encountered: