Skip to content

Commit

Permalink
Improve flexibility of unit tests with respect to available Python ve…
Browse files Browse the repository at this point in the history
…rsions (#8397)
  • Loading branch information
jakob-keller authored Sep 2, 2023
1 parent eb8ada5 commit 02448cf
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 22 deletions.
23 changes: 10 additions & 13 deletions tests/masonry/builders/test_editable_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from cleo.io.null_io import NullIO
from deepdiff import DeepDiff
from poetry.core.constraints.version import Version
from poetry.core.packages.package import Package

from poetry.factory import Factory
from poetry.masonry.builders.editable import EditableBuilder
Expand Down Expand Up @@ -125,8 +126,14 @@ def test_builder_installs_proper_files_for_standard_packages(
== "[console_scripts]\nbaz=bar:baz.boom.bim\nfoo=foo:bar\n"
"fox=fuz.foo:bar.baz\n\n"
)

metadata = """\
python_classifiers = "\n".join(
f"Classifier: Programming Language :: Python :: {version}"
for version in sorted(
Package.AVAILABLE_PYTHONS,
key=lambda x: tuple(map(int, x.split("."))),
)
)
metadata = f"""\
Metadata-Version: 2.1
Name: simple-project
Version: 1.2.3
Expand All @@ -138,17 +145,7 @@ def test_builder_installs_proper_files_for_standard_packages(
Author-email: [email protected]
Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
{python_classifiers}
Classifier: Topic :: Software Development :: Build Tools
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Project-URL: Documentation, https://python-poetry.org/docs
Expand Down
23 changes: 14 additions & 9 deletions tests/test_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
from cleo.io.buffered_io import BufferedIO
from deepdiff import DeepDiff
from packaging.utils import canonicalize_name
from poetry.core.constraints.version import Version
from poetry.core.constraints.version import parse_constraint
from poetry.core.packages.package import Package
from poetry.core.packages.vcs_dependency import VCSDependency

from poetry.exceptions import PoetryException
Expand Down Expand Up @@ -131,15 +133,18 @@ def test_create_poetry(fixture_dir: FixtureDirGetter) -> None:

assert package.all_classifiers == [
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
*(
f"Programming Language :: Python :: {version}"
for version in sorted(
Package.AVAILABLE_PYTHONS,
key=lambda x: tuple(map(int, x.split("."))),
)
if package.python_constraint.allows_any(
parse_constraint(version + ".*")
if len(version) == 1
else Version.parse(version)
)
),
"Topic :: Software Development :: Build Tools",
"Topic :: Software Development :: Libraries :: Python Modules",
]
Expand Down

0 comments on commit 02448cf

Please sign in to comment.