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

CleanCut / green / 11804829668

12 Nov 2024 08:04PM UTC coverage: 95.515% (+0.3%) from 95.232%
11804829668

Pull #302

github

web-flow
Merge 8634fcca3 into 2caf6e824
Pull Request #302: Fix breakage due to setuptools 72.0.0

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

3 existing lines in 1 file now uncovered.

1299 of 1360 relevant lines covered (95.51%)

0.96 hits per line

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

93.48
/green/command.py
1
"""Registers the green command with setuptools."""
2

3
from __future__ import annotations
1✔
4

5
import functools
1✔
6
import sys
1✔
7
from typing import TYPE_CHECKING
1✔
8

9
from setuptools import Command
1✔
10

11
from green.config import parseArguments
1✔
12
from green.cmdline import main
1✔
13

14
if TYPE_CHECKING:
15
    from argparse import Action
16

17

18
def get_user_options() -> list[tuple[str, str | None, str | None]]:
1✔
19
    # When running "python setup.py --help-commands", setup.py will call this
20
    # function -- but green isn't actually being called.
21
    if "--help-commands" in sys.argv:
1✔
22
        return []
1✔
23

24
    args = parseArguments()
1✔
25
    options: list[tuple[str, str | None, str | None]] = []
1✔
26

27
    action: Action
28
    for action in args.store_opt.actions:
1✔
29
        names = [name.lstrip("-") for name in action.option_strings]
1✔
30
        short_name: str | None
31
        if len(names) == 1:
1✔
32
            full_name = names[0]
1✔
33
            short_name = None
1✔
34
        else:
35
            # TODO: We might want to pick the longer of the two for full_name.
36
            full_name = names[1]
1✔
37
            short_name = names[0]
1✔
38
        if not action.const:
1✔
39
            full_name += "="
1✔
40
        options.append((full_name, short_name, action.help))
1✔
41

42
    return options
1✔
43

44

45
class green(Command):
1✔
46
    command_name = "green"
1✔
47
    description = "Run unit tests using green"
1✔
48

49
    @functools.cached_property
1✔
50
    def user_options(self) -> list[tuple[str, str | None, str | None]]:
1✔
51
        return get_user_options()
1✔
52

53
    def initialize_options(self) -> None:
1✔
54
        for name, _, _ in self.user_options:
1✔
55
            setattr(self, name.replace("-", "_").rstrip("="), None)
1✔
56

57
    def finalize_options(self) -> None:
1✔
58
        pass
1✔
59

60
    def run(self) -> None:
1✔
61
        self.ensure_finalized()
1✔
62

63
        if self.distribution.install_requires:
1✔
UNCOV
64
            self.distribution.fetch_build_eggs(self.distribution.install_requires)
×
65

66
        # TODO: Remove this once setuptools >= 72.0.0 is ubiquitous, since it no longer supports the
67
        # "test" subcommand
68
        if (
1✔
69
            hasattr(self.distribution, "tests_require")
70
            and self.distribution.tests_require
71
        ):
UNCOV
72
            self.distribution.fetch_build_eggs(self.distribution.tests_require)
×
73

74
        # TODO: Remove this once setuptools >= 72.0.0 is ubiquitous, since it no longer supports the
75
        # "test" subcommand
76
        script_args = self.distribution.script_args[1:]
1✔
77
        if (
1✔
78
            hasattr(self.distribution, "test_suite")
79
            and self.distribution.test_suite is not None
80
        ):
UNCOV
81
            script_args.append(self.distribution.test_suite)
×
82

83
        error_code = main(script_args)
1✔
84
        if error_code:
1✔
85
            sys.exit(error_code)
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