Add basic command line framework
`wutta setup` is the only real sub/command yet, and it does nothing
This commit is contained in:
parent
417f7e5c38
commit
005f43d14e
15 changed files with 742 additions and 12 deletions
|
@ -27,6 +27,32 @@ class TestLoadEntryPoints(TestCase):
|
|||
self.assertTrue(len(result) >= 1)
|
||||
self.assertIn('pip', result)
|
||||
|
||||
def test_basic_pre_python_3_10(self):
|
||||
|
||||
# the goal here is to get coverage for code which would only
|
||||
# run on python 3,9 and older, but we only need that coverage
|
||||
# if we are currently testing python 3.10+
|
||||
if sys.version_info.major == 3 and sys.version_info.minor < 10:
|
||||
pytest.skip("this test is not relevant before python 3.10")
|
||||
|
||||
import importlib.metadata
|
||||
real_entry_points = importlib.metadata.entry_points()
|
||||
|
||||
class FakeEntryPoints(dict):
|
||||
def get(self, group, default):
|
||||
return real_entry_points.select(group=group)
|
||||
|
||||
importlib = MagicMock()
|
||||
importlib.metadata.entry_points.return_value = FakeEntryPoints()
|
||||
|
||||
with patch.dict('sys.modules', **{'importlib': importlib}):
|
||||
|
||||
# load some entry points which should "always" be present,
|
||||
# even in a testing environment. basic sanity check
|
||||
result = util.load_entry_points('console_scripts', ignore_errors=True)
|
||||
self.assertTrue(len(result) >= 1)
|
||||
self.assertIn('pip', result)
|
||||
|
||||
def test_error(self):
|
||||
|
||||
# skip if < 3.8
|
||||
|
@ -34,7 +60,7 @@ class TestLoadEntryPoints(TestCase):
|
|||
pytest.skip("this requires python 3.8 for entry points via importlib")
|
||||
|
||||
entry_point = MagicMock()
|
||||
entry_point.load.side_effect = NotImplementedError("just a testin")
|
||||
entry_point.load.side_effect = NotImplementedError
|
||||
|
||||
entry_points = MagicMock()
|
||||
entry_points.select.return_value = [entry_point]
|
||||
|
@ -94,7 +120,7 @@ class TestLoadEntryPoints(TestCase):
|
|||
orig_import = __import__
|
||||
|
||||
entry_point = MagicMock()
|
||||
entry_point.load.side_effect = NotImplementedError("just a testin")
|
||||
entry_point.load.side_effect = NotImplementedError
|
||||
|
||||
iter_entry_points = MagicMock(return_value=[entry_point])
|
||||
pkg_resources = MagicMock(iter_entry_points=iter_entry_points)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue