Sets PYMUPDF_MESSAGE to `message` and PYMUPDF_LOG to `log`, runs `pymupdf internal`, and checks lines stdout and stderr match regexes in `expect_out` and `expect_err`. Note that we enclose regexes in `^...$`.
(
expect_out,
expect_err,
message=None,
log=None,
)
| 1093 | del sys.path[0] |
| 1094 | pipcl.show_system() |
| 1095 | def check( |
| 1096 | expect_out, |
| 1097 | expect_err, |
| 1098 | message=None, |
| 1099 | log=None, |
| 1100 | ): |
| 1101 | ''' |
| 1102 | Sets PYMUPDF_MESSAGE to `message` and PYMUPDF_LOG to `log`, runs |
| 1103 | `pymupdf internal`, and checks lines stdout and stderr match regexes in |
| 1104 | `expect_out` and `expect_err`. Note that we enclose regexes in `^...$`. |
| 1105 | ''' |
| 1106 | env = dict() |
| 1107 | if log: |
| 1108 | env['PYMUPDF_LOG'] = log |
| 1109 | if message: |
| 1110 | env['PYMUPDF_MESSAGE'] = message |
| 1111 | command = 'pymupdf internal' |
| 1112 | print(f'Running: {command}', flush=1) |
| 1113 | if env: |
| 1114 | print(f'with:') |
| 1115 | for key in sorted(env.keys()): |
| 1116 | print(f' {key}={shlex.quote(env[key])}') |
| 1117 | env = os.environ | env |
| 1118 | cp = subprocess.run(command, shell=1, check=1, capture_output=1, env=env, text=True) |
| 1119 | |
| 1120 | check_lines(expect_out, cp.stdout) |
| 1121 | check_lines(expect_err, cp.stderr) |
| 1122 | |
| 1123 | print(f'test_cli_out(): {Py_GIL_DISABLED=}') |
| 1124 | print(f'test_cli_out(): {gil_enabled=}') |
no test coverage detected
searching dependent graphs…