Running tox -e py36 fails before any test is executed

Bug #1783765 reported by Pedro Guimarães
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Designate Charm
Invalid
Undecided
Pedro Guimarães
OpenStack Designate-Bind Charm
Invalid
Undecided
Pedro Guimarães
charms.openstack
Fix Released
Undecided
Pedro Guimarães

Bug Description

Running tox -e py36 fails to execute unit tests for Designate and Designate-Bind
Log of the error is:

--- import errors ---
Failed to import test module: unit_tests.test_designate_bind_handlers
Traceback (most recent call last):
  File "/home/ubuntu/charm-designate-bind/.tox/py36/lib/python3.6/site-packages/unittest2/loader.py", line 456, in _find_test_path
    module = self._get_module_from_name(name)
  File "/home/ubuntu/charm-designate-bind/.tox/py36/lib/python3.6/site-packages/unittest2/loader.py", line 395, in _get_module_from_name
    __import__(name)
  File "/home/ubuntu/charm-designate-bind/unit_tests/test_designate_bind_handlers.py", line 23, in <module>
    import reactive.designate_bind_handlers as handlers
  File "src/reactive/designate_bind_handlers.py", line 21, in <module>
    @reactive.when_not(\'installed\')
  File "/home/ubuntu/charm-designate-bind/.tox/py36/lib/python3.6/site-packages/charms/reactive/decorators.py", line 95, in _when_decorator
    handler = Handler.get(action, endpoint_name)
  File "/home/ubuntu/charm-designate-bind/.tox/py36/lib/python3.6/site-packages/charms/reactive/bus.py", line 90, in get
    cls._HANDLERS[action_id] = cls(action, suffix)
  File "/home/ubuntu/charm-designate-bind/.tox/py36/lib/python3.6/site-packages/charms/reactive/bus.py", line 114, in __init__
    self._action_id = _short_action_id(action, suffix)
  File "/home/ubuntu/charm-designate-bind/.tox/py36/lib/python3.6/site-packages/charms/reactive/bus.py", line 59, in _short_action_id
    filepath = os.path.relpath(action.__code__.co_filename, hookenv.charm_dir())
  File "/home/ubuntu/charm-designate-bind/.tox/py36/lib/python3.6/posixpath.py", line 465, in relpath
    start = os.fspath(start)
TypeError: expected str, bytes or os.PathLike object, not MagicMock

It seems that hookenv has been mocked without any return_value set for charm_dir() and because of that, os.path.relpath ends up failing as it receives a MagicMock instance instead of an actual path.
One can reproduce this bug by cloning charm-designate from repo and running tox -e py36.

description: updated
Changed in charm-designate:
assignee: nobody → Pedro Guimarães (pguimaraes)
Changed in charm-designate-bind:
assignee: nobody → Pedro Guimarães (pguimaraes)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to charm-designate (master)

Fix proposed to branch: master
Review: https://review.openstack.org/586204

Changed in charm-designate:
status: New → In Progress
Changed in charm-designate-bind:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to charm-designate-bind (master)

Fix proposed to branch: master
Review: https://review.openstack.org/586207

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Fix proposed to branch: master
Review: https://review.openstack.org/586260

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to charm-designate (master)

Fix proposed to branch: master
Review: https://review.openstack.org/586283

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on charm-designate (master)

Change abandoned by Pedro Guimarães (<email address hidden>) on branch: master
Review: https://review.openstack.org/586283

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Change abandoned by Pedro Guimarães (<email address hidden>) on branch: master
Review: https://review.openstack.org/586204

Revision history for this message
Pedro Guimarães (pguimaraes) wrote :

Fix for charms.openstack is: https://review.openstack.org/#/c/586506/

Changed in charms.openstack:
status: New → Fix Released
status: Fix Released → New
assignee: nobody → Pedro Guimarães (pguimaraes)
status: New → Fix Released
description: updated
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on charm-designate-bind (master)

Change abandoned by Pedro Guimarães (<email address hidden>) on branch: master
Review: https://review.openstack.org/586207

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Change abandoned by Pedro Guimarães (<email address hidden>) on branch: master
Review: https://review.openstack.org/586260

James Page (james-page)
Changed in charm-designate:
status: In Progress → Invalid
Changed in charm-designate-bind:
status: In Progress → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.