diff options
| author | Michael Merickel <github@m.merickel.org> | 2024-02-04 23:55:45 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-04 23:55:45 -0700 |
| commit | 151ebdc003a3a372017fdf73c14fbebcc550535d (patch) | |
| tree | ff2b210b87aff4715450acc38d695a6c6a8abf61 /tests/test_scripts/test_pshell.py | |
| parent | a6fe1a1e38d6a3fb955fa950b671fc736ac9f4d0 (diff) | |
| parent | 13dbb8507e9f1acaaad8caf74a1441e1f723a346 (diff) | |
| download | pyramid-151ebdc003a3a372017fdf73c14fbebcc550535d.tar.gz pyramid-151ebdc003a3a372017fdf73c14fbebcc550535d.tar.bz2 pyramid-151ebdc003a3a372017fdf73c14fbebcc550535d.zip | |
Merge pull request #3749 from Pylons/remove-pkg-resources-from-scripts
Remove pkg resources from scripts
Diffstat (limited to 'tests/test_scripts/test_pshell.py')
| -rw-r--r-- | tests/test_scripts/test_pshell.py | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/tests/test_scripts/test_pshell.py b/tests/test_scripts/test_pshell.py index de7e17496..a5eeee045 100644 --- a/tests/test_scripts/test_pshell.py +++ b/tests/test_scripts/test_pshell.py @@ -1,4 +1,5 @@ import os +import sys import unittest from . import dummy @@ -50,7 +51,10 @@ class TestPShellCommand(unittest.TestCase): return cmd def _makeEntryPoints(self, command, shells): - command.pkg_resources = dummy.DummyPkgResources(shells) + entry_points = [ + DummyEntryPoint(name, value) for name, value in shells.items() + ] + command.importlib_metadata = DummyImportlibMetadata(entry_points) def test_command_loads_default_shell(self): command = self._makeOne() @@ -430,3 +434,35 @@ class Test_main(unittest.TestCase): def test_it(self): result = self._callFUT(['pshell']) self.assertEqual(result, 2) + + +class DummyImportlibMetadata: + def __init__(self, entry_points): + self._entry_points = entry_points + + def entry_points(self): + return DummyEntryPoints(self._entry_points) + + +class DummyEntryPoints: + def __init__(self, entry_points): + self._entry_points = entry_points + + if sys.version_info >= (3, 10): + + def select(self, **kw): + return iter(self._entry_points) + + else: # pragma no cover + + def get(self, key): + return list(self._entry_points) + + +class DummyEntryPoint: + def __init__(self, name, value): + self.name = name + self.value = value + + def load(self): + return self.value |
