"tox -e unit" fails on the master branch

Bug #1833095 reported by Alex Kavanagh
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
logrotate-charm
Fix Released
Medium
Diko Parvanov

Bug Description

"tox -e unit" on the master branch fails with errors:

tests/unit/test_logrotate.py::TestLogrotateHelper::test_pytest PASSED [ 16%]
tests/unit/test_logrotate.py::TestLogrotateHelper::test_daily_retention_count ERROR [ 33%]
tests/unit/test_logrotate.py::TestLogrotateHelper::test_weekly_retention_count ERROR [ 50%]
tests/unit/test_logrotate.py::TestLogrotateHelper::test_monthly_retention_count ERROR [ 66%]
tests/unit/test_logrotate.py::TestLogrotateHelper::test_yearly_retention_count ERROR [ 83%]
tests/unit/test_logrotate.py::TestLogrotateHelper::test_modify_content ERROR

An example of the error is:

=========================================================== ERRORS ===========================================================
______________________________ ERROR at setup of TestLogrotateHelper.test_daily_retention_count ______________________________

name = 'lib_logrotate.hookenv'

    def resolve(name):
        # simplified from zope.dottedname
        parts = name.split(".")

        used = parts.pop(0)
        found = __import__(used)
        for part in parts:
            used += "." + part
            try:
                found = getattr(found, part)
            except AttributeError:
                pass
            else:
                continue
            # we use explicit un-nesting of the handling block in order
            # to avoid nested exceptions on python 3
            try:
> __import__(used)
E ModuleNotFoundError: No module named 'lib_logrotate.hookenv'; 'lib_logrotate' is not a package

.tox/unit/lib/python3.6/site-packages/_pytest/monkeypatch.py:63: ModuleNotFoundError

During handling of the above exception, another exception occurred:

monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f460d8dc908>

    @pytest.fixture
    def mock_hookenv_config(monkeypatch):
        import yaml

        def mock_config():
            cfg = {}
            yml = yaml.load(open('./config.yaml'))

            # Load all defaults
            for key, value in yml['options'].items():
                cfg[key] = value['default']

            # Manually add cfg from other layers
            # cfg['my-other-layer'] = 'mock'
            return cfg

> monkeypatch.setattr('lib_logrotate.hookenv.config', mock_config)
E ImportError: import error in lib_logrotate.hookenv: No module named 'lib_logrotate.hookenv'; 'lib_logrotate' is not a package

---

I expect that this is causing all of the errors (i.e. the import error).

Unfortunately, without a solid baseline in master, it's difficult/impossible to say whether a new merge proposal is going to break things. Also, it's not really possible to say whether the charm code is doing what is expected in a functional environment if the unit tests are not passing as it's not known whether the code is correct, the tests are correct, or neither is. The unit testing contract is broken.

Related branches

Diko Parvanov (dparv)
Changed in logrotate-charm:
status: New → Confirmed
importance: Undecided → Medium
assignee: nobody → Diko Parvanov (dparv)
Revision history for this message
Diko Parvanov (dparv) wrote :
Diko Parvanov (dparv)
Changed in logrotate-charm:
status: Confirmed → Fix Committed
Revision history for this message
Alex Kavanagh (ajkavanagh) wrote :

I've just pulled master and this is not "fix committed" ... there may be a branch for it, but it is not yet merged.

Changed in logrotate-charm:
status: Fix Committed → In Progress
Revision history for this message
Diko Parvanov (dparv) wrote :

@Alex, it should be fine now.

Changed in logrotate-charm:
status: In Progress → Fix Committed
Diko Parvanov (dparv)
Changed in logrotate-charm:
status: Fix Committed → Fix Released
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.