Skip to content

Commit

Permalink
python pre 3.9 compatibily
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianLudwig committed Feb 6, 2022
1 parent 42be5c1 commit ecf64a4
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tests/plugins/test_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,23 @@ def _verify_module(module, plugin_module_name):
_verify_module(obj, plugin_module_name)


def removesuffix(self: str, suffix: str) -> str:
# compatibility for pre 3.9
if suffix and self.endswith(suffix):
return self[: -len(suffix)]
else:
return self[:]


def test_plugins_correct_has_attr():
module = amqtt.plugins
for file in glob(join(dirname(module.__file__), "**/*.py"), recursive=True):
if not isfile(file):
continue

name = file.replace("/", ".")
name = name[name.find(module.__name__) : -3].removesuffix(".__init__")
name = name[name.find(module.__name__) : -3]
name = removesuffix(name, ".__init__")

__import__(name)

Expand Down

0 comments on commit ecf64a4

Please sign in to comment.