(
*args: Any,
count: bool = True,
std: bool = False,
)
| 37 | |
| 38 | @staticmethod |
| 39 | def main( |
| 40 | *args: Any, |
| 41 | count: bool = True, |
| 42 | std: bool = False, |
| 43 | ) -> Union[int, tuple[int, str, str]]: |
| 44 | args = tuple(str(arg) for arg in args) |
| 45 | if count: |
| 46 | args = ("--count", *args) |
| 47 | code = cs_.main(*args) |
| 48 | frame = inspect.currentframe() |
| 49 | assert frame is not None |
| 50 | frame = frame.f_back |
| 51 | assert frame is not None |
| 52 | capsys = frame.f_locals["capsys"] |
| 53 | stdout, stderr = capsys.readouterr() |
| 54 | assert code in (EX_OK, EX_USAGE, EX_DATAERR, EX_CONFIG) |
| 55 | if code == EX_DATAERR: # have some misspellings |
| 56 | code = int(stderr.split("\n")[-2]) |
| 57 | elif code == EX_OK and count: |
| 58 | code = int(stderr.split("\n")[-2]) |
| 59 | assert code == 0 |
| 60 | if std: |
| 61 | return (code, stdout, stderr) |
| 62 | return code |
| 63 | |
| 64 | |
| 65 | cs = MainWrapper() |
no outgoing calls
no test coverage detected