From 832cae47693b4c07a1fa826dce13b9af7a91ebaf Mon Sep 17 00:00:00 2001 From: Theron Luhn Date: Sun, 24 Aug 2025 21:35:04 -0700 Subject: Add `get_spec` to asset sources. --- tests/test_config/test_assets.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'tests/test_config/test_assets.py') diff --git a/tests/test_config/test_assets.py b/tests/test_config/test_assets.py index 1d2cfcd5c..5c535ec6c 100644 --- a/tests/test_config/test_assets.py +++ b/tests/test_config/test_assets.py @@ -916,6 +916,24 @@ class TestPackageAssetSource(AssetSourceIntegrationTests, unittest.TestCase): klass = self._getTargetClass() return klass(package, prefix) + def test_get_spec(self): + source = self._makeOne('') + self.assertEqual( + source.get_spec('test_assets.py'), + 'tests.test_config:test_assets.py', + ) + + def test_get_spec_with_prefix(self): + source = self._makeOne('test_assets.py') + self.assertEqual( + source.get_spec(''), + 'tests.test_config:test_assets.py', + ) + + def test_get_spec_file_doesnt_exist(self): + source = self._makeOne('') + self.assertIsNone(source.get_spec('wont_exist')) + class TestFSAssetSource(AssetSourceIntegrationTests, unittest.TestCase): def _getTargetClass(self): @@ -927,6 +945,23 @@ class TestFSAssetSource(AssetSourceIntegrationTests, unittest.TestCase): klass = self._getTargetClass() return klass(os.path.join(base_prefix, prefix)) + def test_get_spec(self): + source = self._makeOne('') + self.assertEqual( + source.get_spec('test_assets.py'), + os.path.join(here, 'test_assets.py'), + ) + + def test_get_spec_with_prefix(self): + source = self._makeOne('test_assets.py') + self.assertEqual( + source.get_spec(''), os.path.join(here, 'test_assets.py') + ) + + def test_get_spec_file_doesnt_exist(self): + source = self._makeOne('') + self.assertEqual(source.get_spec('wont_exist'), None) + class TestDirectoryOverride(unittest.TestCase): def _getTargetClass(self): -- cgit v1.2.3