Skip to content

Commit 11f2834

Browse files
committed
Create helper method to handle test map deletion
Signed-off-by: Jono Yang <jyang@nexb.com>
1 parent 9bc3e43 commit 11f2834

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

tests/test_purl_validator.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ def tearDown(self):
3434
fileutils.delete(purl_map.parent)
3535
return super().tearDown()
3636

37+
def create_purl_map(self, purls):
38+
purl_map_loc = purl_validator.create_purl_map(purls)
39+
self.created_purl_maps.append(purl_map_loc)
40+
return purl_map_loc
41+
3742
def test_purl_validator_create_purl_map_entry(self):
3843
test_purl1 = PackageURL(type="npm", namespace="@test", name="test", version="1.0")
3944
test_purl2 = "pkg:npm/test2@2.0"
@@ -56,16 +61,14 @@ def test_purl_validator_create_purl_map_entry(self):
5661
test_purl4 = []
5762
purls = [test_purl1, test_purl2]
5863

59-
purl_map_loc = purl_validator.create_purl_map(purls)
60-
self.created_purl_maps.append(purl_map_loc)
61-
64+
purl_map_loc = self.create_purl_map(purls)
6265
purl_map = purl_validator.PurlValidator.load_map(purl_map_loc)
6366
expected_results = [(b"npm/@test/test", 1), (b"npm/test2", 1)]
6467
results = [(k, v) for k, v in purl_map.items()]
6568
self.assertEqual(expected_results, results)
6669

6770
with self.assertRaises(ValueError):
68-
purl_validator.create_purl_map([test_purl3])
71+
self.create_purl_map([test_purl3])
6972

7073
with self.assertRaises(ValueError):
71-
purl_validator.create_purl_map([test_purl4])
74+
self.create_purl_map([test_purl4])

0 commit comments

Comments
 (0)