Skip to content

Commit daf680b

Browse files
committed
Simplify TestKit glue + add option to choose interpreter verion
1 parent 6daec5b commit daf680b

File tree

5 files changed

+30
-29
lines changed

5 files changed

+30
-29
lines changed

testkit/_common.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import os
2+
import subprocess
3+
import sys
4+
5+
6+
TEST_BACKEND_VERSION = os.getenv("TEST_BACKEND_VERSION", "python")
7+
8+
9+
def run(args, env=None):
10+
return subprocess.run(
11+
args, universal_newlines=True, stdout=sys.stdout, stderr=sys.stderr,
12+
check=True, env=env
13+
)
14+
15+
16+
def run_python(args, env=None):
17+
run([TEST_BACKEND_VERSION, "-W", "error", *args], env=env)

testkit/backend.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919

2020

2121
import os
22-
import subprocess
23-
import sys
22+
23+
from _common import run_python
2424

2525

2626
if __name__ == "__main__":
27-
cmd = ["python", "-W", "error", "-m", "testkitbackend"]
27+
cmd = ["-m", "testkitbackend"]
2828
if "TEST_BACKEND_SERVER" in os.environ:
2929
cmd.append(os.environ["TEST_BACKEND_SERVER"])
30-
subprocess.check_call(cmd, stdout=sys.stdout, stderr=sys.stderr)
30+
run_python(cmd)

testkit/build.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,11 @@
2424
"""
2525

2626

27-
import subprocess
28-
import sys
29-
30-
31-
def run(args, env=None):
32-
subprocess.run(args, universal_newlines=True, stdout=sys.stdout,
33-
stderr=sys.stderr, check=True, env=env)
27+
from _common import run_python
3428

3529

3630
if __name__ == "__main__":
37-
run(["python", "setup.py", "build"])
38-
run(["python", "-m", "pip", "install", "-U", "pip"])
39-
run(["python", "-m", "pip", "install", "-Ur",
40-
"testkitbackend/requirements.txt"])
31+
run_python(["setup.py", "build"])
32+
run_python(["-m", "pip", "install", "-U", "pip"])
33+
run_python(["-m", "pip", "install", "-Ur",
34+
"testkitbackend/requirements.txt"])

testkit/integration.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,8 @@
1818
# limitations under the License.
1919

2020

21-
import subprocess
22-
23-
24-
def run(args):
25-
subprocess.run(
26-
args, universal_newlines=True, stderr=subprocess.STDOUT, check=True)
21+
from _common import run_python
2722

2823

2924
if __name__ == "__main__":
30-
run(["python", "-W", "error", "-m", "tox", "-f", "integration"])
25+
run_python(["-m", "tox", "-f", "integration"])

testkit/unittests.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,8 @@
1818
# limitations under the License.
1919

2020

21-
import subprocess
22-
23-
24-
def run(args):
25-
subprocess.run(
26-
args, universal_newlines=True, stderr=subprocess.STDOUT, check=True)
21+
from _common import run_python
2722

2823

2924
if __name__ == "__main__":
30-
run(["python", "-W", "error", "-m", "tox", "-f", "unit"])
25+
run_python(["-m", "tox", "-f", "unit"])

0 commit comments

Comments
 (0)