Skip to content

Commit

Permalink
Add test capturing failed expectation. Ref #489.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Jul 23, 2024
1 parent 9693e99 commit 48f6b14
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,32 @@ def test_unique_distributions(self):
assert len(after) == len(before)


class InvalidMetadataTests(fixtures.OnSysPath, fixtures.SiteDir, unittest.TestCase):
@staticmethod
def make_pkg(name, files=dict(METADATA="VERSION: 1.0")):
"""
Create metadata for a dist-info package with name and files.
"""
return {
f'{name}.dist-info': files,
}

@__import__('pytest').mark.xfail(reason="#489")
def test_valid_dists_preferred(self):
"""
Dists with metadata should be preferred when discovered by name.
Ref python/importlib_metadata#489.
"""
# create three dists with the valid one in the middle (lexicographically)
# such that on most file systems, the valid one is never naturally first.
fixtures.build_files(self.make_pkg('foo-4.0', files={}), self.site_dir)
fixtures.build_files(self.make_pkg('foo-4.1'), self.site_dir)
fixtures.build_files(self.make_pkg('foo-4.2', files={}), self.site_dir)
dist = Distribution.from_name('foo')
assert dist.version == "1.0"


class NonASCIITests(fixtures.OnSysPath, fixtures.SiteDir, unittest.TestCase):
@staticmethod
def pkg_with_non_ascii_description(site_dir):
Expand Down

0 comments on commit 48f6b14

Please sign in to comment.