forked from bazel-contrib/rules_python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsystem_python_zipapp_test.py
More file actions
33 lines (27 loc) · 954 Bytes
/
system_python_zipapp_test.py
File metadata and controls
33 lines (27 loc) · 954 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import os
import subprocess
import unittest
import zipfile
class SystemPythonZipAppTest(unittest.TestCase):
def test_zipapp_runnable(self):
zipapp_path = os.environ["TEST_ZIPAPP"]
self.assertTrue(os.path.exists(zipapp_path))
self.assertTrue(os.path.isfile(zipapp_path))
try:
output = (
subprocess.check_output([zipapp_path], stderr=subprocess.STDOUT)
.decode("utf-8")
.strip()
)
except subprocess.CalledProcessError as e:
self.fail(
"exit code: {}\n"
" command: {}\n"
"===== stdout/stderr start ==={}===== stdout/stderr end ====".format(
e.returncode, e.cmd, e.output.decode("utf-8")
)
)
self.assertIn("Hello from zipapp", output)
self.assertIn("dep:", output)
if __name__ == "__main__":
unittest.main()