Comment 8 for bug 1937173

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

The load error is intentional (it is a bad module name).
But the test expects the stringified exception
  bad
while on the second execution it gets:
  No module named 'breezy.testingplugins.some_error'

This checked error message comes from breezy/plugin.py
It is set by:
  return record_plugin_warning(
      'Unable to load plugin %r from %r: %s' % (name, dir, e))

On the first call the exception is of type 'Exception', the second time 'ModuleNotFoundError'.
The test prepares a simple .py file "some_error.py" which contains the
    raise Exception("bad")
which it checks upon.

The load does directly call __import__ with the same string each time.
  __import__("breezy.testingplugins.some_error")

In the good case the raised exception thereby is like:
  File "/build/breezy-xbGxjH/breezy-3.2.1/breezy/plugin.py", line 431, in _load_plugin_module
    __import__(_MODULE_PREFIX + name)
  File "/tmp/testbzr-e53aok06.tmp/breezy.tests.test_plugins.TestLoadingPlugins.test_plugin_with_error/work/./some_error.py", line 1, in <module>
    raise Exception("bad")

And in the bad case it does not find the file.
If I call the __import__ function myself twice it reports "ModuleNotFoundError" every time.
Semething in the setup must make it able to load that and this is what breaks in the second execution.