• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pantsbuild / pants / 20826906489

08 Jan 2026 06:09PM UTC coverage: 80.192% (-0.08%) from 80.274%
20826906489

Pull #22987

github

web-flow
Merge aa52dd80f into 0d471f924
Pull Request #22987: WIP DRAFT: Pex 2.77.1 tests

3 of 3 new or added lines in 1 file covered. (100.0%)

90 existing lines in 15 files now uncovered.

78714 of 98157 relevant lines covered (80.19%)

3.36 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.91
/src/python/pants/backend/python/util_rules/dists_test.py
1
# Copyright 2021 Pants project contributors (see CONTRIBUTORS.md).
2
# Licensed under the Apache License, Version 2.0 (see LICENSE).
3

4
from __future__ import annotations
1✔
5

6
import pytest
1✔
7

8
from pants.backend.python.util_rules import dists, pex
1✔
9
from pants.backend.python.util_rules.dists import (
1✔
10
    BuildSystem,
11
    DistBuildRequest,
12
    DistBuildResult,
13
    distutils_repr,
14
)
15
from pants.backend.python.util_rules.interpreter_constraints import InterpreterConstraints
1✔
16
from pants.backend.python.util_rules.pex_requirements import PexRequirements
1✔
17
from pants.engine.fs import CreateDigest, FileContent
1✔
18
from pants.engine.internals.native_engine import Digest
1✔
19
from pants.testutil.python_interpreter_selection import skip_unless_python39_present
1✔
20
from pants.testutil.rule_runner import QueryRule, RuleRunner
1✔
21
from pants.util.frozendict import FrozenDict
1✔
22

23

24
@pytest.fixture
1✔
25
def rule_runner() -> RuleRunner:
1✔
26
    ret = RuleRunner(
1✔
27
        rules=[
28
            *dists.rules(),
29
            *pex.rules(),
30
            QueryRule(DistBuildResult, [DistBuildRequest]),
31
        ],
32
    )
33
    ret.set_options(
1✔
34
        [],
35
        env_inherit={"PATH", "PYENV_ROOT", "HOME"},
36
    )
37
    return ret
1✔
38

39

40
def do_test_backend_shim(rule_runner: RuleRunner, constraints: str) -> None:
1✔
41
    setup_py = "from setuptools import setup; setup(name='foobar', version='1.2.3')"
1✔
42
    input_digest = rule_runner.request(
1✔
43
        Digest, [CreateDigest([FileContent("setup.py", setup_py.encode())])]
44
    )
45
    req = DistBuildRequest(
1✔
46
        build_system=BuildSystem(
47
            PexRequirements(
48
                # NB: These are the last versions compatible with Python 2.7.
49
                ["setuptools==44.1.1", "wheel==0.37.1"]
50
            ),
51
            "setuptools.build_meta",
52
        ),
53
        interpreter_constraints=InterpreterConstraints([constraints]),
54
        build_wheel=True,
55
        build_sdist=True,
56
        input=input_digest,
57
        working_directory="",
58
        dist_source_root=".",
59
        build_time_source_roots=tuple(),
60
        output_path="dist",
61
        wheel_config_settings=FrozenDict({"setting1": ("value1",), "setting2": ("value2",)}),
62
    )
63
    res = rule_runner.request(DistBuildResult, [req])
1✔
64

UNCOV
65
    is_py2 = "2.7" in constraints
×
UNCOV
66
    assert res.sdist_path == "dist/foobar-1.2.3.tar.gz"
×
UNCOV
67
    assert res.wheel_path == f"dist/foobar-1.2.3-py{'2' if is_py2 else '3'}-none-any.whl"
×
68

69

70
@skip_unless_python39_present
1✔
71
def test_works_with_python39(rule_runner: RuleRunner) -> None:
1✔
72
    do_test_backend_shim(rule_runner, constraints="CPython==3.9.*")
1✔
73

74

75
def test_distutils_repr() -> None:
1✔
76
    testdata = {
1✔
77
        "foo": "bar",
78
        "baz": {"qux": [123, 456], "quux": ("abc", b"xyz"), "corge": {1, 2, 3}},
79
        "various_strings": ["x'y", "aaa\nbbb"],
80
    }
81
    expected = """
1✔
82
{
83
    'foo': 'bar',
84
    'baz': {
85
        'qux': [
86
            123,
87
            456,
88
        ],
89
        'quux': (
90
            'abc',
91
            'xyz',
92
        ),
93
        'corge': {
94
            1,
95
            2,
96
            3,
97
        },
98
    },
99
    'various_strings': [
100
        'x\\\'y',
101
        \"\"\"aaa\nbbb\"\"\",
102
    ],
103
}
104
""".strip()
105
    assert expected == distutils_repr(testdata)
1✔
106

107

108
def test_distutils_repr_none() -> None:
1✔
109
    assert "None" == distutils_repr(None)
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc