#114 Python 3: Tests are broken: KeyError: "'fedmsg' not found in dict_keys(['dummy'])"
Closed: Invalid 6 years ago Opened 6 years ago by frantisekz.

This works just fine on Python 2, but fails horribly on Python 3:

=================================== FAILURES ===================================
________________________ TestMessaging.test_load_plugin ________________________

self = <testing.test_general.TestMessaging object at 0x7f56c8774048>

    def test_load_plugin(self):
        plugin = messaging.load_messaging_plugin('dummy', {})
        assert isinstance(plugin, messaging.DummyPlugin)
        try:
>           plugin = messaging.load_messaging_plugin('fedmsg', {})

testing/test_general.py:188: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

name = 'fedmsg', kwargs = {}

    def load_messaging_plugin(name, kwargs):
        """ Instantiate and return the appropriate messaging plugin. """
        points = pkg_resources.iter_entry_points('resultsdb.messaging.plugins')
        classes = {'dummy': DummyPlugin}
        classes.update(dict([(point.name, point.load()) for point in points]))

        log.debug("Found the following installed messaging plugin %r" % classes)
        if name not in classes:
>           raise KeyError("%r not found in %r" % (name, classes.keys()))
E           KeyError: "'fedmsg' not found in dict_keys(['dummy'])"

resultsdb/messaging.py:183: KeyError

During handling of the above exception, another exception occurred:

self = <testing.test_general.TestMessaging object at 0x7f56c8774048>

    def test_load_plugin(self):
        plugin = messaging.load_messaging_plugin('dummy', {})
        assert isinstance(plugin, messaging.DummyPlugin)
        try:
            plugin = messaging.load_messaging_plugin('fedmsg', {})
        except KeyError as err:
>           if "not found" in err.message:
E           AttributeError: 'KeyError' object has no attribute 'message'

testing/test_general.py:190: AttributeError
----------------------------- Captured stderr call -----------------------------
--------------------------------------------------------------------------------
DEBUG in messaging [/builddir/build/BUILD/resultsdb-2.1.1/resultsdb/messaging.py:181]:
Found the following installed messaging plugin {'dummy': <class 'resultsdb.messaging.DummyPlugin'>}
--------------------------------------------------------------------------------
[messaging.py:181] 2018-07-16 13:07:48 DEBUG   Found the following installed messaging plugin {'dummy': <class 'resultsdb.messaging.DummyPlugin'>}
--------------------------------------------------------------------------------
DEBUG in messaging [/builddir/build/BUILD/resultsdb-2.1.1/resultsdb/messaging.py:191]:
Instantiating plugin <class 'resultsdb.messaging.DummyPlugin'> named dummy
--------------------------------------------------------------------------------
[messaging.py:191] 2018-07-16 13:07:48 DEBUG   Instantiating plugin <class 'resultsdb.messaging.DummyPlugin'> named dummy
--------------------------------------------------------------------------------
DEBUG in messaging [/builddir/build/BUILD/resultsdb-2.1.1/resultsdb/messaging.py:181]:
Found the following installed messaging plugin {'dummy': <class 'resultsdb.messaging.DummyPlugin'>}
--------------------------------------------------------------------------------
[messaging.py:181] 2018-07-16 13:07:48 DEBUG   Found the following installed messaging plugin {'dummy': <class 'resultsdb.messaging.DummyPlugin'>}
===================== 1 failed, 61 passed in 10.58 seconds =====================

How exactly are you running the testsute? I can't reproduce it on my setup (running tox in the git repo).
Did you execute python setup.py develop before runinning the testsuite as instructe in the docs?

Uff, my bad. I am executing the testsuite during the build process and I've overlooked I am running it against python2_sitelib ... :(

Metadata Update from @frantisekz:
- Issue close_status updated to: Invalid
- Issue status updated to: Closed (was: Open)

6 years ago

@frantisekz There IMO still is some merit to the issue - the "other exception" in the code should be handled better - if you have a look at the code, the line checking if there is "not found" in the err.message then produces a "helpful tip" saying that you need to run the python setup.py develop in order for it to work properly. Seems like that changed in Py3 and should be fixed. I'll edit and re-open the issue, if you don't mind (could also create a new one, but that is just wasting resources, isn't it! :D )

Log in to comment on this ticket.

Metadata