Skip to content

Commit 2df8b5a

Browse files
committed
Consolidate logic for generating minimal metadata.
1 parent 9c80e09 commit 2df8b5a

File tree

1 file changed

+9
-24
lines changed

1 file changed

+9
-24
lines changed

tests/test_main.py

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -76,46 +76,31 @@ def test_resolve_without_attr(self):
7676

7777
class NameNormalizationTests(fixtures.OnSysPath, fixtures.SiteDir, unittest.TestCase):
7878
@staticmethod
79-
def pkg_with_dashes(site_dir):
79+
def make_pkg(name):
8080
"""
81-
Create minimal metadata for a package with dashes
82-
in the name (and thus underscores in the filename).
81+
Create minimal metadata for a dist-info package with
82+
the indicated name on the file system.
8383
"""
84-
contents = {
85-
'my_pkg.dist-info': {
84+
return {
85+
f'{name}.dist-info': {
8686
'METADATA': 'VERSION: 1.0\n',
8787
},
8888
}
89-
fixtures.build_files(contents, site_dir)
90-
return 'my-pkg'
9189

9290
def test_dashes_in_dist_name_found_as_underscores(self):
9391
"""
9492
For a package with a dash in the name, the dist-info metadata
9593
uses underscores in the name. Ensure the metadata loads.
9694
"""
97-
pkg_name = self.pkg_with_dashes(self.site_dir)
98-
assert version(pkg_name) == '1.0'
99-
100-
@staticmethod
101-
def pkg_with_mixed_case(site_dir):
102-
"""
103-
Create minimal metadata for a package with mixed case
104-
in the name.
105-
"""
106-
contents = {
107-
'CherryPy.dist-info': {
108-
'METADATA': 'VERSION: 1.0\n',
109-
},
110-
}
111-
fixtures.build_files(contents, site_dir)
112-
return 'CherryPy'
95+
fixtures.build_files(self.make_pkg('my_pkg'), self.site_dir)
96+
assert version('my-pkg') == '1.0'
11397

11498
def test_dist_name_found_as_any_case(self):
11599
"""
116100
Ensure the metadata loads when queried with any case.
117101
"""
118-
pkg_name = self.pkg_with_mixed_case(self.site_dir)
102+
pkg_name = 'CherryPy'
103+
fixtures.build_files(self.make_pkg(pkg_name), self.site_dir)
119104
assert version(pkg_name) == '1.0'
120105
assert version(pkg_name.lower()) == '1.0'
121106
assert version(pkg_name.upper()) == '1.0'

0 commit comments

Comments
 (0)