diff options
Diffstat (limited to 'run_tests')
-rwxr-xr-x | run_tests | 24 |
1 files changed, 21 insertions, 3 deletions
@@ -13,10 +13,28 @@ | |||
13 | # See the License for the specific language governing permissions and | 13 | # See the License for the specific language governing permissions and |
14 | # limitations under the License. | 14 | # limitations under the License. |
15 | 15 | ||
16 | """Wrapper to run pytest with the right settings.""" | 16 | """Wrapper to run black and pytest with the right settings.""" |
17 | 17 | ||
18 | import os | ||
19 | import subprocess | ||
18 | import sys | 20 | import sys |
19 | import pytest | 21 | import pytest |
20 | 22 | ||
21 | if __name__ == '__main__': | 23 | |
22 | sys.exit(pytest.main(sys.argv[1:])) | 24 | def run_black(): |
25 | """Returns the exit code of running `black --check`.""" | ||
26 | dirpath = os.path.dirname(os.path.realpath(__file__)) | ||
27 | return subprocess.run( | ||
28 | [sys.executable, "-m", "black", "--check", dirpath], check=False | ||
29 | ).returncode | ||
30 | |||
31 | |||
32 | def main(argv): | ||
33 | """The main entry.""" | ||
34 | black_ret = 0 if argv else run_black() | ||
35 | pytest_ret = pytest.main(argv) | ||
36 | return 0 if not black_ret and not pytest_ret else 1 | ||
37 | |||
38 | |||
39 | if __name__ == "__main__": | ||
40 | sys.exit(main(sys.argv[1:])) | ||