Skip to content

Commit 83eeeaf

Browse files
committed
Fix assertion for all supported Python versions
1 parent f3ec56d commit 83eeeaf

File tree

2 files changed

+38
-10
lines changed

2 files changed

+38
-10
lines changed

CHANGES.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
the package, which were largely undocumented, had no test coverage, and
2424
were last updated over a decade ago, have been removed.
2525

26+
- When importing a plugin fails, the error message printed by ``supervisord``
27+
now includes the Python exception message for easier debugging.
28+
Patch by Sandro Jaeckel.
29+
2630
4.3.0 (2025-08-23)
2731
------------------
2832

supervisor/tests/test_options.py

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2642,10 +2642,18 @@ def test_event_listener_pool_result_handler_unimportable_ImportError(self):
26422642
instance.process_groups_from_parser(config)
26432643
self.fail('nothing raised')
26442644
except ValueError as exc:
2645-
self.assertEqual(exc.args[0],
2646-
'thisishopefullynotanimportablepackage:nonexistent cannot be '
2647-
'resolved within [eventlistener:cat]: No module named '
2648-
'\'thisishopefullynotanimportablepackage\'')
2645+
possible_msgs = (
2646+
# py27, py34
2647+
"thisishopefullynotanimportablepackage:nonexistent cannot be "
2648+
"resolved within [eventlistener:cat]: No module named "
2649+
"thisishopefullynotanimportablepackage"
2650+
2651+
# py35+
2652+
"thisishopefullynotanimportablepackage:nonexistent cannot be "
2653+
"resolved within [eventlistener:cat]: No module named "
2654+
"'thisishopefullynotanimportablepackage'"
2655+
)
2656+
self.assertTrue(exc.args[0] in possible_msgs, exc.args[0])
26492657

26502658
def test_event_listener_pool_result_handler_unimportable_AttributeError(self):
26512659
text = lstrip("""\
@@ -2662,10 +2670,18 @@ def test_event_listener_pool_result_handler_unimportable_AttributeError(self):
26622670
instance.process_groups_from_parser(config)
26632671
self.fail('nothing raised')
26642672
except ValueError as exc:
2665-
self.assertEqual(exc.args[0],
2666-
'supervisor.tests.base:nonexistent cannot be '
2667-
'resolved within [eventlistener:cat]: module '
2668-
'\'supervisor.tests.base\' has no attribute \'nonexistent\'')
2673+
possible_msgs = (
2674+
# py27, py34
2675+
"supervisor.tests.base:nonexistent cannot be resolved "
2676+
"within [eventlistener:cat]: 'module' object "
2677+
"has no attribute 'nonexistent'",
2678+
2679+
# py35+
2680+
"supervisor.tests.base:nonexistent cannot be resolved "
2681+
"within [eventlistener:cat]: module 'supervisor.tests.base' "
2682+
"has no attribute 'nonexistent'"
2683+
)
2684+
self.assertTrue(exc.args[0] in possible_msgs, exc.args[0])
26692685

26702686
def test_event_listener_pool_noeventsline(self):
26712687
text = lstrip("""\
@@ -3217,8 +3233,16 @@ def test_rpcinterfaces_from_parser_factory_not_importable(self):
32173233
'rpcinterface:')
32183234
self.fail('nothing raised')
32193235
except ValueError as exc:
3220-
self.assertEqual(exc.args[0], 'nonexistent cannot be resolved '
3221-
'within [rpcinterface:dummy]: No module named \'nonexistent\'')
3236+
possible_msgs = (
3237+
# py27, py34
3238+
"nonexistent cannot be resolved within [rpcinterface:dummy]: "
3239+
"No module named nonexistent",
3240+
3241+
# py35+
3242+
"nonexistent cannot be resolved within [rpcinterface:dummy]: "
3243+
"No module named 'nonexistent'",
3244+
)
3245+
self.assertTrue(exc.args[0] in possible_msgs, exc.args[0])
32223246

32233247
def test_clear_autochildlogdir(self):
32243248
dn = tempfile.mkdtemp()

0 commit comments

Comments
 (0)