Skip to content

Commit

Permalink
test: add test for the fixer fix
Browse files Browse the repository at this point in the history
  • Loading branch information
wey-gu committed Jan 21, 2024
1 parent 9a34e81 commit af5b1f5
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/pdm/cli/commands/fix/fixers.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ def check(self) -> bool:
def fix(self) -> None:
# Copy the project settings
settings = self.project.pyproject.settings.copy()

# Pop the package type and convert it to a distribution type
package_type = settings.pop("package-type")
dist = bool(package_type == "library")
settings["distribution"] = dist

# Update the project settings with the new distribution type
self.project.pyproject._data["tool"].pop("pdm")
self.project.pyproject.settings.update(settings)

# Write the updated settings back to the project
self.project.pyproject.write(False)
7 changes: 7 additions & 0 deletions tests/cli/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,3 +305,10 @@ def test_install_requirement_with_extras(project, pdm, working_set):
pdm(["lock", "-Gsocks"], obj=project, strict=True)
pdm(["sync", "-Gsocks"], obj=project, strict=True)
assert "pysocks" in working_set


def test_fix_package_type_and_update(fixture_project, pdm, working_set):
project = fixture_project("test-package-type-fixer")
pdm(["fix", "project-type"], obj=project, strict=True)
pdm(["update"], obj=project, strict=True)
assert "test-package-type-fixer" in working_set
23 changes: 23 additions & 0 deletions tests/fixtures/projects/test-package-type-fixer/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[build-system]
requires = ["pdm-backend"]
build-backend = "pdm.backend"

[project]

version = "0.0.1"
dependencies = []
name = "test-package-type-fixer"


[tool.pdm.version]
source = "file"
path = "src/test_package_type_fixer/__init__.py"

[tool.pdm]
package-type = "application"

[tool.pdm.dev-dependencies]

dev = [
"black>=23.12.1"
]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__verson__ = '0.1.0'

0 comments on commit af5b1f5

Please sign in to comment.