question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Failing tests on Python 3.5

See original GitHub issue

On Ubuntu 16.04 with Python 3.5.2. This isn’t the target platform obviously but I still think the tests should either skip or succeed.

============================================================= FAILURES ==============================================================
_________________________________________________________ test_i2c_cleanup __________________________________________________________

    def test_i2c_cleanup():
        serial = i2c(bus=smbus, address=0x9F)
        serial.cleanup()
>       smbus.close.assert_called_once()

tests/test_serial.py:71: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <Mock name='mock.close' id='139995073637848'>, name = 'assert_called_once'

    def __getattr__(self, name):
        if name in {'_mock_methods', '_mock_unsafe'}:
            raise AttributeError(name)
        elif self._mock_methods is not None:
            if name not in self._mock_methods or name in _all_magics:
                raise AttributeError("Mock object has no attribute %r" % name)
        elif _is_magic(name):
            raise AttributeError(name)
        if not self._mock_unsafe:
            if name.startswith(('assert', 'assret')):
>               raise AttributeError(name)
E               AttributeError: assert_called_once

/usr/local/lib/python3.5/unittest/mock.py:583: AttributeError
_________________________________________________________ test_spi_cleanup __________________________________________________________

    def test_spi_cleanup():
        serial = spi(gpio=gpio, spi=spidev, port=9, device=1)
        serial.cleanup()
        verify_spi_init(9, 1)
>       spidev.close.assert_called_once()

tests/test_serial.py:109: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <Mock name='mock.close' id='139995073628592'>, name = 'assert_called_once'

    def __getattr__(self, name):
        if name in {'_mock_methods', '_mock_unsafe'}:
            raise AttributeError(name)
        elif self._mock_methods is not None:
            if name not in self._mock_methods or name in _all_magics:
                raise AttributeError("Mock object has no attribute %r" % name)
        elif _is_magic(name):
            raise AttributeError(name)
        if not self._mock_unsafe:
            if name.startswith(('assert', 'assret')):
>               raise AttributeError(name)
E               AttributeError: assert_called_once

/usr/local/lib/python3.5/unittest/mock.py:583: AttributeError
___________________________________________________________ test_display ____________________________________________________________

    def test_display():
        device = sh1106(serial)
        serial.reset_mock()
    
        recordings = []
    
        def data(data):
            recordings.append({'data': data})
    
        def command(*cmd):
            recordings.append({'command': list(cmd)})
    
        serial.command = Mock(side_effect=command)
        serial.data = Mock(side_effect=data)
    
        # Use the same drawing primitives as the demo
        with canvas(device) as draw:
            baseline_data.primitives(device, draw)
    
>       serial.data.assert_called()

tests/test_sh1106.py:35: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <Mock name='mock.data' id='139995111772848'>, name = 'assert_called'

    def __getattr__(self, name):
        if name in {'_mock_methods', '_mock_unsafe'}:
            raise AttributeError(name)
        elif self._mock_methods is not None:
            if name not in self._mock_methods or name in _all_magics:
                raise AttributeError("Mock object has no attribute %r" % name)
        elif _is_magic(name):
            raise AttributeError(name)
        if not self._mock_unsafe:
            if name.startswith(('assert', 'assret')):
>               raise AttributeError(name)
E               AttributeError: assert_called

/usr/local/lib/python3.5/unittest/mock.py:583: AttributeError

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
thijstriemstracommented, Dec 8, 2016

Fixed with #77.

0reactions
thijstriemstracommented, Dec 7, 2016

Here’s Travis showing the same error on Python 3.5 (only): https://travis-ci.org/rm-hull/ssd1306/jobs/182130845

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issue 28874: test_logging fails and freezes - Python tracker
while testing my build of cpython it hangs on test 198/404 and will not continue unless interrupted with ctrl-C. the build is fairly...
Read more >
tests fail on raspbian with Python 3.5 (#274) · Issues - GitLab
On Raspbian, Python 3.5 seems to be the latest available via apt install. While I can apply the workaround in my case and...
Read more >
Message "test test_gdb failed" while installing Python-3.5.1 on ...
While installing Python-3.5.1 on Linux ubuntu 14.04 LTS, after running command: make test. I got a message: test test_gdb failed. I've made a...
Read more >
Bug #1467644 “Test failures on Python 3.5” : Bugs : zope.testing
... don't know whether the bug is due to a change in Python 3.5 or something in zope.testing not yet caught up. Here's...
Read more >
1384606 – py3 test_os.ExtendedAttributeTests fails on XFS
test_os started to fail with the latest python3 build on s390x, ... last): File "/builddir/build/BUILD/Python-3.5.2/Lib/test/test_os.py", ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found