Skip to content

Commit

Permalink
Add test capturing expectation. Ref #404
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Dec 3, 2023
1 parent 8439918 commit 9c2b0b4
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/fixtures.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import sys
import copy
import json
import shutil
import pathlib
import tempfile
Expand Down Expand Up @@ -127,6 +128,31 @@ def make_uppercase(self):
build_files(files, self.site_dir)


class DistInfoPkgEditable(DistInfoPkg):
"""
Package with a PEP 660 direct_url.json.
"""

some_hash = '524127ce937f7cb65665130c695abd18ca386f60bb29687efb976faa1596fdcc'
files: FilesSpec = {
'distinfo_pkg-1.0.0.dist-info': {
'direct_url.json': json.dumps(
{
"archive_info": {
"hash": f"sha256={some_hash}",
"hashes": {"sha256": f"{some_hash}"},
},
"url": "file:///path/to/distinfo_pkg-1.0.0.editable-py3-none-any.whl",
}
)
},
}

def setUp(self):
super().setUp()
build_files(DistInfoPkgEditable.files, self.site_dir)


class DistInfoPkgWithDot(OnSysPath, SiteDir):
files: FilesSpec = {
"pkg_dot-1.0.0.dist-info": {
Expand Down
7 changes: 7 additions & 0 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,3 +457,10 @@ def import_names_from_package(package_name):
# sources_fallback-pkg has one import ('sources_fallback') inferred from
# SOURCES.txt (top_level.txt and installed-files.txt is missing)
assert import_names_from_package('sources_fallback-pkg') == {'sources_fallback'}


class EditableDistributionTest(fixtures.DistInfoPkgEditable):
def test_origin(self):
dist = Distribution.from_name('distinfo-pkg')
assert dist.origin.url.endswith('.whl')
assert dist.origin.archive_info.hashes.sha256

0 comments on commit 9c2b0b4

Please sign in to comment.