-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
addons: Make sure to iterate over valid entry points
I.e. cast pkg_resources.EntryPoint to corresponding importlib.metadata.EntryPoint because the source of these are from downstream clients which might still construct them.
- Loading branch information
1 parent
02a4aa8
commit 904fdea
Showing
5 changed files
with
62 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from types import SimpleNamespace | ||
from unittest import TestCase | ||
|
||
from ..pkgmeta import ensure_valid_entry_point, EntryPoint | ||
|
||
|
||
class TestPkgmeta(TestCase): | ||
def test_ensure_valid_entry_point(self): | ||
ep = ensure_valid_entry_point(EntryPoint("a", "b", "c")) | ||
self.assertIsInstance(ep, EntryPoint) | ||
self.assertEqual(ep.name, "a") | ||
self.assertEqual(ep.value, "b") | ||
self.assertEqual(ep.group, "c") | ||
ep = ensure_valid_entry_point( | ||
SimpleNamespace(name="a", value="b", group="c", dist=None) | ||
) | ||
self.assertEqual(ep.name, "a") | ||
self.assertEqual(ep.value, "b") | ||
self.assertEqual(ep.group, "c") | ||
|
||
try: | ||
from pkg_resources import EntryPoint as PREntryPoint | ||
except ImportError: | ||
return | ||
ep = ensure_valid_entry_point(PREntryPoint("a", "b")) | ||
self.assertEqual(ep.name, "a") | ||
self.assertEqual(ep.value, "b") |