Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from pants.testutil.python_interpreter_selection import (
all_major_minor_python_versions,
skip_unless_python38_present,
skip_unless_python39_present,
)
from pants.testutil.python_rule_runner import PythonRuleRunner
from pants.testutil.rule_runner import QueryRule
Expand Down Expand Up @@ -236,27 +235,6 @@ class Foo:
assert fmt_result.did_change is False


@skip_unless_python39_present
def test_works_with_python39(rule_runner: PythonRuleRunner) -> None:
"""Black's typed-ast dependency does not understand Python 3.9, so we must instead run Black
with Python 3.9 when relevant."""
content = dedent(
"""\
@lambda _: int
def replaced(x: bool) -> str:
return "42" if x is True else "1/137"
"""
)
rule_runner.write_files(
{"f.py": content, "BUILD": "python_sources(name='t', interpreter_constraints=['>=3.9'])"}
)
tgt = rule_runner.get_target(Address("", target_name="t", relative_file_path="f.py"))
fmt_result = run_black(rule_runner, [tgt], expected_ics=">=3.9")
assert "1 file left unchanged" in fmt_result.stderr
assert fmt_result.output == rule_runner.make_snapshot({"f.py": content})
assert fmt_result.did_change is False


def test_stub_files(rule_runner: PythonRuleRunner) -> None:
rule_runner.write_files(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
all_major_minor_python_versions,
skip_unless_all_pythons_present,
skip_unless_python38_present,
skip_unless_python39_present,
)
from pants.testutil.python_rule_runner import PythonRuleRunner
from pants.util.resources import read_sibling_resource
Expand Down Expand Up @@ -357,26 +356,6 @@ def test_works_with_python38(rule_runner: PythonRuleRunner) -> None:
assert_success(rule_runner, tgt, extra_args=extra_args)


@skip_unless_python39_present
def test_works_with_python39(rule_runner: PythonRuleRunner) -> None:
"""MyPy's typed-ast dependency does not understand Python 3.9, so we must instead run MyPy with
Python 3.9 when relevant."""
rule_runner.write_files(
{
f"{PACKAGE}/f.py": dedent(
"""\
@lambda _: int
def replaced(x: bool) -> str:
return "42" if x is True else "1/137"
"""
),
f"{PACKAGE}/BUILD": "python_sources(interpreter_constraints=['>=3.9'])",
}
)
tgt = rule_runner.get_target(Address(PACKAGE, relative_file_path="f.py"))
assert_success(rule_runner, tgt)


def test_run_only_on_specified_files(rule_runner: PythonRuleRunner) -> None:
rule_runner.write_files(
{
Expand Down
12 changes: 6 additions & 6 deletions src/python/pants/base/specs_integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from textwrap import dedent

from pants.testutil.pants_integration_test import PantsResult, run_pants, setup_tmpdir
from pants.testutil.python_interpreter_selection import skip_unless_python39_present
from pants.testutil.python_interpreter_selection import skip_unless_python310_present

SOURCES = {
# NB: This uses recursive globs for the `python_sources` and `python_tests` target generators,
Expand Down Expand Up @@ -65,7 +65,7 @@ def run(args: list[str]) -> PantsResult:
[
"--backend-packages=pants.backend.python",
"--backend-packages=pants.backend.experimental.go",
"--python-interpreter-constraints=['==3.9.*']",
"--python-interpreter-constraints=['==3.10.*']",
"--pants-ignore=__pycache__",
*args,
]
Expand All @@ -74,7 +74,7 @@ def run(args: list[str]) -> PantsResult:
return result


@skip_unless_python39_present
@skip_unless_python310_present

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(We should maybe have an "oldest supported Python for bundled tools" shortcut.)

def test_address_literal() -> None:
"""Semantics:

Expand All @@ -91,7 +91,7 @@ def test_address_literal() -> None:
assert f"{tmpdir}/py:tests" not in test_result


@skip_unless_python39_present
@skip_unless_python310_present
def test_sibling_addresses() -> None:
"""Semantics:

Expand Down Expand Up @@ -127,7 +127,7 @@ def test_sibling_addresses() -> None:
assert f"{tmpdir}/py:tests" not in test_result


@skip_unless_python39_present
@skip_unless_python310_present
def test_descendent_addresses() -> None:
"""Semantics are the same as sibling addresses, only recursive."""
with setup_tmpdir(SOURCES) as tmpdir:
Expand All @@ -148,7 +148,7 @@ def test_descendent_addresses() -> None:
assert f"{tmpdir}/py:tests" not in test_result


@skip_unless_python39_present
@skip_unless_python310_present
def test_file_arg() -> None:
"""Semantics: find the 'owning' target, using generated target rather than target generator
when possible (regardless of project introspection vs. "build" goal).
Expand Down
Loading