Skip to content
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

Open
colemickens opened this issue Mar 28, 2020 · 5 comments
Open

test failure (python3 related?) #45

colemickens opened this issue Mar 28, 2020 · 5 comments

Comments

@colemickens
Copy link

I'm getting some test failures while trying to package this for NixOS.

Any suggestions?

> nix-build -A python3Packages.alarmdecoder
these derivations will be built:
  /nix/store/djkyiv0n4si16ddq2b87cfj02db7jyg1-python3.7-alarmdecoder-1.13.9.drv
building '/nix/store/djkyiv0n4si16ddq2b87cfj02db7jyg1-python3.7-alarmdecoder-1.13.9.drv'...
Sourcing python-remove-tests-dir-hook
Sourcing python-catch-conflicts-hook.sh
Sourcing python-remove-bin-bytecode-hook.sh
Sourcing setuptools-build-hook
Using setuptoolsBuildPhase
Using setuptoolsShellHook
Sourcing pip-install-hook
Using pipInstallPhase
Sourcing python-imports-check-hook.sh
Using pythonImportsCheckPhase
Sourcing setuptools-check-hook
Using setuptoolsCheckPhase
unpacking sources
unpacking source archive /nix/store/4wvlpznnsc6j4zk6d1c2935ylppjaqrj-source
source root is source
setting SOURCE_DATE_EPOCH to timestamp 315619200 of file source/test/test_zonetracking.py
patching sources
configuring
no configure script, doing nothing
building
Executing setuptoolsBuildPhase
running bdist_wheel
running build
running build_py
creating build
creating build/lib
creating build/lib/alarmdecoder
copying alarmdecoder/zonetracking.py -> build/lib/alarmdecoder
copying alarmdecoder/util.py -> build/lib/alarmdecoder
copying alarmdecoder/states.py -> build/lib/alarmdecoder
copying alarmdecoder/panels.py -> build/lib/alarmdecoder
copying alarmdecoder/decoder.py -> build/lib/alarmdecoder
copying alarmdecoder/__init__.py -> build/lib/alarmdecoder
creating build/lib/alarmdecoder/devices
copying alarmdecoder/devices/usb_device.py -> build/lib/alarmdecoder/devices
copying alarmdecoder/devices/socket_device.py -> build/lib/alarmdecoder/devices
copying alarmdecoder/devices/serial_device.py -> build/lib/alarmdecoder/devices
copying alarmdecoder/devices/base_device.py -> build/lib/alarmdecoder/devices
copying alarmdecoder/devices/__init__.py -> build/lib/alarmdecoder/devices
creating build/lib/alarmdecoder/event
copying alarmdecoder/event/event.py -> build/lib/alarmdecoder/event
copying alarmdecoder/event/__init__.py -> build/lib/alarmdecoder/event
creating build/lib/alarmdecoder/messages
copying alarmdecoder/messages/rf_message.py -> build/lib/alarmdecoder/messages
copying alarmdecoder/messages/panel_message.py -> build/lib/alarmdecoder/messages
copying alarmdecoder/messages/expander_message.py -> build/lib/alarmdecoder/messages
copying alarmdecoder/messages/base_message.py -> build/lib/alarmdecoder/messages
copying alarmdecoder/messages/aui_message.py -> build/lib/alarmdecoder/messages
copying alarmdecoder/messages/__init__.py -> build/lib/alarmdecoder/messages
creating build/lib/alarmdecoder/messages/lrr
copying alarmdecoder/messages/lrr/system.py -> build/lib/alarmdecoder/messages/lrr
copying alarmdecoder/messages/lrr/message.py -> build/lib/alarmdecoder/messages/lrr
copying alarmdecoder/messages/lrr/events.py -> build/lib/alarmdecoder/messages/lrr
copying alarmdecoder/messages/lrr/__init__.py -> build/lib/alarmdecoder/messages/lrr
running egg_info
creating alarmdecoder.egg-info
writing alarmdecoder.egg-info/PKG-INFO
writing dependency_links to alarmdecoder.egg-info/dependency_links.txt
writing requirements to alarmdecoder.egg-info/requires.txt
writing top-level names to alarmdecoder.egg-info/top_level.txt
writing manifest file 'alarmdecoder.egg-info/SOURCES.txt'
reading manifest file 'alarmdecoder.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'alarmdecoder.egg-info/SOURCES.txt'
running build_scripts
creating build/scripts-3.7
copying and adjusting bin/ad2-sslterm -> build/scripts-3.7
copying and adjusting bin/ad2-firmwareupload -> build/scripts-3.7
changing mode of build/scripts-3.7/ad2-sslterm from 644 to 755
changing mode of build/scripts-3.7/ad2-firmwareupload from 644 to 755
installing to build/bdist.linux-x86_64/wheel
running install
running install_lib
creating build/bdist.linux-x86_64
creating build/bdist.linux-x86_64/wheel
creating build/bdist.linux-x86_64/wheel/alarmdecoder
creating build/bdist.linux-x86_64/wheel/alarmdecoder/messages
creating build/bdist.linux-x86_64/wheel/alarmdecoder/messages/lrr
copying build/lib/alarmdecoder/messages/lrr/__init__.py -> build/bdist.linux-x86_64/wheel/alarmdecoder/messages/lrr
copying build/lib/alarmdecoder/messages/lrr/events.py -> build/bdist.linux-x86_64/wheel/alarmdecoder/messages/lrr
copying build/lib/alarmdecoder/messages/lrr/message.py -> build/bdist.linux-x86_64/wheel/alarmdecoder/messages/lrr
copying build/lib/alarmdecoder/messages/lrr/system.py -> build/bdist.linux-x86_64/wheel/alarmdecoder/messages/lrr
copying build/lib/alarmdecoder/messages/__init__.py -> build/bdist.linux-x86_64/wheel/alarmdecoder/messages
copying build/lib/alarmdecoder/messages/aui_message.py -> build/bdist.linux-x86_64/wheel/alarmdecoder/messages
copying build/lib/alarmdecoder/messages/base_message.py -> build/bdist.linux-x86_64/wheel/alarmdecoder/messages
copying build/lib/alarmdecoder/messages/expander_message.py -> build/bdist.linux-x86_64/wheel/alarmdecoder/messages
copying build/lib/alarmdecoder/messages/panel_message.py -> build/bdist.linux-x86_64/wheel/alarmdecoder/messages
copying build/lib/alarmdecoder/messages/rf_message.py -> build/bdist.linux-x86_64/wheel/alarmdecoder/messages
creating build/bdist.linux-x86_64/wheel/alarmdecoder/event
copying build/lib/alarmdecoder/event/__init__.py -> build/bdist.linux-x86_64/wheel/alarmdecoder/event
copying build/lib/alarmdecoder/event/event.py -> build/bdist.linux-x86_64/wheel/alarmdecoder/event
creating build/bdist.linux-x86_64/wheel/alarmdecoder/devices
copying build/lib/alarmdecoder/devices/__init__.py -> build/bdist.linux-x86_64/wheel/alarmdecoder/devices
copying build/lib/alarmdecoder/devices/base_device.py -> build/bdist.linux-x86_64/wheel/alarmdecoder/devices
copying build/lib/alarmdecoder/devices/serial_device.py -> build/bdist.linux-x86_64/wheel/alarmdecoder/devices
copying build/lib/alarmdecoder/devices/socket_device.py -> build/bdist.linux-x86_64/wheel/alarmdecoder/devices
copying build/lib/alarmdecoder/devices/usb_device.py -> build/bdist.linux-x86_64/wheel/alarmdecoder/devices
copying build/lib/alarmdecoder/__init__.py -> build/bdist.linux-x86_64/wheel/alarmdecoder
copying build/lib/alarmdecoder/decoder.py -> build/bdist.linux-x86_64/wheel/alarmdecoder
copying build/lib/alarmdecoder/panels.py -> build/bdist.linux-x86_64/wheel/alarmdecoder
copying build/lib/alarmdecoder/states.py -> build/bdist.linux-x86_64/wheel/alarmdecoder
copying build/lib/alarmdecoder/util.py -> build/bdist.linux-x86_64/wheel/alarmdecoder
copying build/lib/alarmdecoder/zonetracking.py -> build/bdist.linux-x86_64/wheel/alarmdecoder
running install_egg_info
Copying alarmdecoder.egg-info to build/bdist.linux-x86_64/wheel/alarmdecoder-1.13.9-py3.7.egg-info
running install_scripts
creating build/bdist.linux-x86_64/wheel/alarmdecoder-1.13.9.data
creating build/bdist.linux-x86_64/wheel/alarmdecoder-1.13.9.data/scripts
copying build/scripts-3.7/ad2-firmwareupload -> build/bdist.linux-x86_64/wheel/alarmdecoder-1.13.9.data/scripts
copying build/scripts-3.7/ad2-sslterm -> build/bdist.linux-x86_64/wheel/alarmdecoder-1.13.9.data/scripts
changing mode of build/bdist.linux-x86_64/wheel/alarmdecoder-1.13.9.data/scripts/ad2-firmwareupload to 755
changing mode of build/bdist.linux-x86_64/wheel/alarmdecoder-1.13.9.data/scripts/ad2-sslterm to 755
adding license file "LICENSE" (matched pattern "LICEN[CS]E*")
creating build/bdist.linux-x86_64/wheel/alarmdecoder-1.13.9.dist-info/WHEEL
creating 'dist/alarmdecoder-1.13.9-py3-none-any.whl' and adding 'build/bdist.linux-x86_64/wheel' to it
adding 'alarmdecoder/__init__.py'
adding 'alarmdecoder/decoder.py'
adding 'alarmdecoder/panels.py'
adding 'alarmdecoder/states.py'
adding 'alarmdecoder/util.py'
adding 'alarmdecoder/zonetracking.py'
adding 'alarmdecoder/devices/__init__.py'
adding 'alarmdecoder/devices/base_device.py'
adding 'alarmdecoder/devices/serial_device.py'
adding 'alarmdecoder/devices/socket_device.py'
adding 'alarmdecoder/devices/usb_device.py'
adding 'alarmdecoder/event/__init__.py'
adding 'alarmdecoder/event/event.py'
adding 'alarmdecoder/messages/__init__.py'
adding 'alarmdecoder/messages/aui_message.py'
adding 'alarmdecoder/messages/base_message.py'
adding 'alarmdecoder/messages/expander_message.py'
adding 'alarmdecoder/messages/panel_message.py'
adding 'alarmdecoder/messages/rf_message.py'
adding 'alarmdecoder/messages/lrr/__init__.py'
adding 'alarmdecoder/messages/lrr/events.py'
adding 'alarmdecoder/messages/lrr/message.py'
adding 'alarmdecoder/messages/lrr/system.py'
adding 'alarmdecoder-1.13.9.data/scripts/ad2-firmwareupload'
adding 'alarmdecoder-1.13.9.data/scripts/ad2-sslterm'
adding 'alarmdecoder-1.13.9.dist-info/LICENSE'
adding 'alarmdecoder-1.13.9.dist-info/METADATA'
adding 'alarmdecoder-1.13.9.dist-info/WHEEL'
adding 'alarmdecoder-1.13.9.dist-info/top_level.txt'
adding 'alarmdecoder-1.13.9.dist-info/RECORD'
removing build/bdist.linux-x86_64/wheel
Finished executing setuptoolsBuildPhase
installing
Executing pipInstallPhase
/build/source/dist /build/source
Processing ./alarmdecoder-1.13.9-py3-none-any.whl
Requirement already satisfied: pyserial>=2.7 in /nix/store/rl6rl4g137pgrg22cnkkqwh8xd43wcx3-python3.7-pyserial-3.4/lib/python3.7/site-packages (from alarmdecoder==1.13.9) (3.4)
Installing collected packages: alarmdecoder
Successfully installed alarmdecoder-1.13.9
/build/source
Finished executing pipInstallPhase
post-installation fixup
shrinking RPATHs of ELF executables and libraries in /nix/store/kx0ja8vxy5dv7f1431jb6s7a6jzn9ph2-python3.7-alarmdecoder-1.13.9
strip is /nix/store/nfs9wf6ipffr9g9ylzb4i9c1i607nxvq-binutils-2.31.1/bin/strip
stripping (with command strip and flags -S) in /nix/store/kx0ja8vxy5dv7f1431jb6s7a6jzn9ph2-python3.7-alarmdecoder-1.13.9/lib  /nix/store/kx0ja8vxy5dv7f1431jb6s7a6jzn9ph2-python3.7-alarmdecoder-1.13.9/bin
patching script interpreter paths in /nix/store/kx0ja8vxy5dv7f1431jb6s7a6jzn9ph2-python3.7-alarmdecoder-1.13.9
checking for references to /build/ in /nix/store/kx0ja8vxy5dv7f1431jb6s7a6jzn9ph2-python3.7-alarmdecoder-1.13.9...
Rewriting #!/nix/store/xb1mp0f16lv23rwhfdc1665v5r20jfmm-python3-3.7.6/bin/python3.7 to #!/nix/store/xb1mp0f16lv23rwhfdc1665v5r20jfmm-python3-3.7.6
wrapping `/nix/store/kx0ja8vxy5dv7f1431jb6s7a6jzn9ph2-python3.7-alarmdecoder-1.13.9/bin/ad2-sslterm'...
Rewriting #!/nix/store/xb1mp0f16lv23rwhfdc1665v5r20jfmm-python3-3.7.6/bin/python3.7 to #!/nix/store/xb1mp0f16lv23rwhfdc1665v5r20jfmm-python3-3.7.6
wrapping `/nix/store/kx0ja8vxy5dv7f1431jb6s7a6jzn9ph2-python3.7-alarmdecoder-1.13.9/bin/ad2-firmwareupload'...
Executing pythonRemoveTestsDir
Finished executing pythonRemoveTestsDir
running install tests
no Makefile or custom buildPhase, doing nothing
pythonCatchConflictsPhase
pythonRemoveBinBytecodePhase
pythonImportsCheckPhase
Executing pythonImportsCheckPhase
Check whether the following modules can be imported: alarmdecoder
setuptoolsCheckPhase
Executing setuptoolsCheckPhase
running test
WARNING: Testing via this command is deprecated and will be removed in a future version. Users looking for a generic test entry point independent of test runner are encouraged to use tox.
running egg_info
writing alarmdecoder.egg-info/PKG-INFO
writing dependency_links to alarmdecoder.egg-info/dependency_links.txt
writing requirements to alarmdecoder.egg-info/requires.txt
writing top-level names to alarmdecoder.egg-info/top_level.txt
reading manifest file 'alarmdecoder.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'alarmdecoder.egg-info/SOURCES.txt'
running build_ext
/build/source/alarmdecoder/decoder.py:605: DeprecationWarning: invalid escape sequence \.
  matches = re.match('^!Sending(\.{1,5})done.*', data)
/build/source/alarmdecoder/messages/panel_message.py:73: DeprecationWarning: invalid escape sequence \[
  _regex = re.compile('^(!KPM:){0,1}(\[[a-fA-F0-9\-]+\]),([a-fA-F0-9]+),(\[[a-fA-F0-9]+\]),(".+")$')
/build/source/alarmdecoder/zonetracking.py:188: DeprecationWarning: invalid escape sequence \d
  zone_regex = re.compile('^CHECK (\d+).*$')
test_alarm_event (test.test_ad2.TestAlarmDecoder) ... ok
test_armed_away_event (test.test_ad2.TestAlarmDecoder) ... ok
test_battery_low_event (test.test_ad2.TestAlarmDecoder) ... ok
test_boot (test.test_ad2.TestAlarmDecoder) ... ok
test_chime_changed_event (test.test_ad2.TestAlarmDecoder) ... ok
test_clear_zone (test.test_ad2.TestAlarmDecoder) ... ok
test_close (test.test_ad2.TestAlarmDecoder) ... ok
test_config_message (test.test_ad2.TestAlarmDecoder) ... /build/source/test/test_ad2.py:232: DeprecationWarning: Please use assertEqual instead.
  self.assertEquals(self._decoder.mode, ADEMCO)
ok
test_expander_message (test.test_ad2.TestAlarmDecoder) ... ok
test_fault (test.test_ad2.TestAlarmDecoder) ... ok
test_fault_wireproblem (test.test_ad2.TestAlarmDecoder) ... ok
test_fire_alarm_event (test.test_ad2.TestAlarmDecoder) ... ok
test_fire_lrr (test.test_ad2.TestAlarmDecoder) ... ok
test_get_config (test.test_ad2.TestAlarmDecoder) ... ok
test_hit_for_faults (test.test_ad2.TestAlarmDecoder) ... ok
test_message (test.test_ad2.TestAlarmDecoder) ... ok
test_message_kpm (test.test_ad2.TestAlarmDecoder) ... ok
test_open (test.test_ad2.TestAlarmDecoder) ... ok
test_panic_v1 (test.test_ad2.TestAlarmDecoder) ... ok
test_panic_v2 (test.test_ad2.TestAlarmDecoder) ... ok
test_power_changed_event (test.test_ad2.TestAlarmDecoder) ... ok
test_ready_changed_event (test.test_ad2.TestAlarmDecoder) ... ok
test_reboot (test.test_ad2.TestAlarmDecoder) ... ok
test_relay_message (test.test_ad2.TestAlarmDecoder) ... ok
test_rfx_message (test.test_ad2.TestAlarmDecoder) ... ok
test_save_config (test.test_ad2.TestAlarmDecoder) ... ok
test_send (test.test_ad2.TestAlarmDecoder) ... ok
test_sending_received (test.test_ad2.TestAlarmDecoder) ... ok
test_zone_bypassed_event (test.test_ad2.TestAlarmDecoder) ... ok
test_zone_fault_and_restore (test.test_ad2.TestAlarmDecoder) ... ok
test_open (test.test_devices.TestSerialDevice) ... ok
test_open_failed (test.test_devices.TestSerialDevice) ... ok
test_open_no_interface (test.test_devices.TestSerialDevice) ... ok
test_read (test.test_devices.TestSerialDevice) ... ok
test_read_exception (test.test_devices.TestSerialDevice) ... ok
test_read_line (test.test_devices.TestSerialDevice) ... /build/source/test/test_devices.py:112: DeprecationWarning: Please use assertEqual instead.
  self.assertEquals(ret, "testing")
ok
test_read_line_exception (test.test_devices.TestSerialDevice) ... ok
test_read_line_timeout (test.test_devices.TestSerialDevice) ... ok
test_write (test.test_devices.TestSerialDevice) ... ok
test_write_exception (test.test_devices.TestSerialDevice) ... ok
test_open (test.test_devices.TestSocketDevice) ... ok
test_open_failed (test.test_devices.TestSocketDevice) ... ok
test_read (test.test_devices.TestSocketDevice) ... ok
test_read_exception (test.test_devices.TestSocketDevice) ... ok
test_read_line (test.test_devices.TestSocketDevice) ... ok
test_read_line_exception (test.test_devices.TestSocketDevice) ... ok
test_read_line_timeout (test.test_devices.TestSocketDevice) ... ok
test_ssl (test.test_devices.TestSocketDevice) ... ERROR
test_ssl_exception (test.test_devices.TestSocketDevice) ... ERROR
test_write (test.test_devices.TestSocketDevice) ... ok
test_write_exception (test.test_devices.TestSocketDevice) ... ok
test_expander_message_parse (test.test_messages.TestMessages) ... ok
test_expander_message_parse_fail (test.test_messages.TestMessages) ... ok
test_lrr_event_code_override (test.test_messages.TestMessages) ... /build/source/test/test_messages.py:88: DeprecationWarning: Please use assertEqual instead.
  self.assertEquals(msg.event_code, LRR_CID_EVENT.OPENCLOSE_BY_USER)  # 400 -> 401
ok
test_lrr_message_parse_fail (test.test_messages.TestMessages) ... ok
test_lrr_message_parse_v1 (test.test_messages.TestMessages) ... ok
test_lrr_message_parse_v2 (test.test_messages.TestMessages) ... ok
test_message_parse (test.test_messages.TestMessages) ... ok
test_message_parse_fail (test.test_messages.TestMessages) ... ok
test_rf_message_parse (test.test_messages.TestMessages) ... ok
test_rf_message_parse_fail (test.test_messages.TestMessages) ... ok
test_ECP_failure (test.test_zonetracking.TestZonetracking) ... ok
test_message_fault_text (test.test_zonetracking.TestZonetracking) ... ok
test_message_ready (test.test_zonetracking.TestZonetracking) ... ok
test_zone_fault (test.test_zonetracking.TestZonetracking) ... ok
test_zone_multi_zone_skip_restore (test.test_zonetracking.TestZonetracking) ... ok
test_zone_out_of_order_fault (test.test_zonetracking.TestZonetracking) ... ok
test_zone_restore (test.test_zonetracking.TestZonetracking) ... ok
test_zone_restore_skip (test.test_zonetracking.TestZonetracking) ... ok
test_zone_timeout_restore (test.test_zonetracking.TestZonetracking) ... ok

======================================================================
ERROR: test_ssl (test.test_devices.TestSocketDevice)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/build/source/test/test_devices.py", line 251, in test_ssl
    with patch.object(socket.socket, '_sock'):
  File "/nix/store/bzvlpxbjp2pp0ag06vl8a1abyy8yr7gl-python3.7-mock-3.0.5/lib/python3.7/site-packages/mock/mock.py", line 1394, in __enter__
    original, local = self.get_original()
  File "/nix/store/bzvlpxbjp2pp0ag06vl8a1abyy8yr7gl-python3.7-mock-3.0.5/lib/python3.7/site-packages/mock/mock.py", line 1368, in get_original
    "{} does not have the attribute {!r}".format(target, name)
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 278, in test_ssl_exception
    with patch.object(socket.socket, '_sock'):
  File "/nix/store/bzvlpxbjp2pp0ag06vl8a1abyy8yr7gl-python3.7-mock-3.0.5/lib/python3.7/site-packages/mock/mock.py", line 1394, in __enter__
    original, local = self.get_original()
  File "/nix/store/bzvlpxbjp2pp0ag06vl8a1abyy8yr7gl-python3.7-mock-3.0.5/lib/python3.7/site-packages/mock/mock.py", line 1368, in get_original
    "{} does not have the attribute {!r}".format(target, name)
AttributeError: <class 'socket.socket'> does not have the attribute '_sock'

----------------------------------------------------------------------
Ran 70 tests in 0.524s

FAILED (errors=2)
Test failed: <unittest.runner.TextTestResult run=70 errors=2 failures=0>
error: Test failed: <unittest.runner.TextTestResult run=70 errors=2 failures=0>
builder for '/nix/store/djkyiv0n4si16ddq2b87cfj02db7jyg1-python3.7-alarmdecoder-1.13.9.drv' failed with exit code 1
error: build of '/nix/store/djkyiv0n4si16ddq2b87cfj02db7jyg1-python3.7-alarmdecoder-1.13.9.drv' failed
> 

@ajschmidt8
Copy link
Collaborator

@colemickens, the unit tests on the master branch should pass now due to 29e7dd1. Can you try re-running the tests? Or if this issue is no longer relevant, feel free to close it. Thanks!

@fabaff
Copy link
Contributor

fabaff commented Jun 1, 2021

The AttributeError is still present with 1.13.11. Checked on NixOS.

============================= 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 ===================

@ajschmidt8
Copy link
Collaborator

The AttributeError is still present with 1.13.11. Checked on NixOS.

okay, I will try to take a look at this soon.

@ajschmidt8
Copy link
Collaborator

@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

@fabaff
Copy link
Contributor

fabaff commented Jun 3, 2021

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 pytest and not with nose. But I get the failures with nose on NixOS as well. The NixOS build system is doing nothing fancy as far as I can tell.

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 nose and pytest.

[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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants