Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Frost Ming <me@frostming.com>
  • Loading branch information
frostming committed Sep 23, 2024
1 parent 91795d1 commit b4cbed8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
6 changes: 5 additions & 1 deletion src/pdm/formats/uv.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ def build_pyproject_toml(self) -> Path:
def _enter_path(self, path: Path) -> Path:
if path.exists():
backup = path.rename(path.with_name(f"{path.name}.bak"))
self.stack.callback(backup.rename, path)

@self.stack.callback
def restore() -> None:
path.unlink(True)
backup.rename(path)
else:
self.stack.callback(path.unlink, True)
return path
Expand Down
10 changes: 5 additions & 5 deletions tests/resolver/test_uv_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ def test_resolve_vcs_requirement(project):

def test_resolve_with_python_requires(project):
requirements = ["urllib3<2; python_version<'3.10'", "urllib3>=2; python_version>='3.10'"]

resolution = resolve(project.environment, requirements, EnvSpec.from_spec(">=3.10"))
packages = list(resolution.packages)
assert len(packages) == 1
assert packages[0].candidate.version.startswith("2.")
if project.python.version_tuple >= (3, 10):
resolution = resolve(project.environment, requirements, EnvSpec.from_spec(">=3.10"))
packages = list(resolution.packages)
assert len(packages) == 1
assert packages[0].candidate.version.startswith("2.")

resolution = resolve(project.environment, requirements, EnvSpec.from_spec(">=3.8"))
packages = list(resolution.packages)
Expand Down

0 comments on commit b4cbed8

Please sign in to comment.