Skip to content

Commit 440aa7c

Browse files
committed
py3test.py to run the unit tests with python3 as a cross check
1 parent d831b11 commit 440aa7c

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

py3test.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env python3.4
2+
"""
3+
Check all the tests work with python3.4 and gpython
4+
5+
Note that this isn't quite the same as running the unit tests - the
6+
unit tests should be preferred. This is a quick check to make sure
7+
the tests run with python3.
8+
"""
9+
10+
import os
11+
import sys
12+
from subprocess import Popen, PIPE, STDOUT
13+
14+
testwith = ("python3.4", "gpython")
15+
16+
def runtests(dirpath, filenames):
17+
"""Run the tests found"""
18+
print("Running tests in %s" % dirpath)
19+
for name in filenames:
20+
if not name.endswith(".py") or name.startswith("lib") or name.startswith("raise"):
21+
continue
22+
print("Testing %s" % name)
23+
fullpath = os.path.join(dirpath, name)
24+
for cmd in testwith:
25+
prog = [cmd, fullpath]
26+
p = Popen(prog, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
27+
stdout, stderr = p.communicate("")
28+
rc = p.returncode
29+
if rc != 0:
30+
print("*** %s %s Fail ***" % (cmd, fullpath))
31+
print("="*60)
32+
sys.stdout.write(stdout.decode("utf-8"))
33+
print("="*60)
34+
35+
def main():
36+
binary = os.path.abspath(__file__)
37+
home = os.path.dirname(binary)
38+
os.chdir(home)
39+
print("Scanning %s for tests" % home)
40+
41+
for dirpath, dirnames, filenames in os.walk("."):
42+
if os.path.basename(dirpath) == "tests":
43+
runtests(dirpath, filenames)
44+
45+
if __name__ == "__main__":
46+
main()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy