Skip to content

Commit

Permalink
fix: empty plugins sections repr (#1738)
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey authored Nov 17, 2023
1 parent e06bec7 commit f2511ae
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/ape_plugins/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,9 @@ def __str__(self) -> str:
if PluginType.AVAILABLE in self.include and self.metadata.available:
sections.append(self.metadata.available)

if not sections:
return ""

# Use a single max length for all the sections.
max_length = max(x.max_name_length for x in sections)

Expand Down
13 changes: 9 additions & 4 deletions tests/functional/test_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ def test_is_available(self):

class TestApePluginsRepr:
def test_str(self, plugin_metadata):
plugin_map = ApePluginsRepr(plugin_metadata)
actual = str(plugin_map)
representation = ApePluginsRepr(plugin_metadata)
actual = str(representation)
expected = f"""
Installed Plugins
installed {VERSION}
Expand All @@ -127,8 +127,8 @@ def test_str(self, plugin_metadata):
assert actual == expected.strip()

def test_str_all_types(self, plugin_metadata):
plugin_map = ApePluginsRepr(plugin_metadata, include=list(PluginType))
actual = str(plugin_map)
representation = ApePluginsRepr(plugin_metadata, include=list(PluginType))
actual = str(representation)
expected = f"""
Core Plugins
run
Expand All @@ -143,3 +143,8 @@ def test_str_all_types(self, plugin_metadata):
available
"""
assert actual == expected.strip()

def test_str_no_plugins(self):
plugins = PluginMetadataList.from_package_names([])
representation = ApePluginsRepr(plugins)
assert str(representation) == ""

0 comments on commit f2511ae

Please sign in to comment.