forked from twisted/twisted
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-python3-tests
executable file
·61 lines (45 loc) · 1.47 KB
/
run-python3-tests
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env python3.3
# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.
"""
This program is intended to run Twisted's test suite under Python 3. As such,
it should go away once Twisted has been fully ported to Python 3. It is only
intended to be used from a Twisted checkout, and implementation can and will
change at any time.
"""
import os
import sys
testModules = []
extraArguments = []
installed = False
twistedPath = os.path.abspath(os.path.dirname(os.path.dirname(sys.argv[0])))
for argument in sys.argv[1:]:
if argument.startswith('-'):
extraArguments.append(argument)
else:
testModules.append(argument)
if "--installed" in extraArguments:
installed = True
extraArguments.pop(extraArguments.index("--installed"))
# Add default arguments.
if not extraArguments:
extraArguments = []
# Add default modules.
if not testModules:
if installed:
from twisted.python.dist3 import testModules
else:
modules = {}
path = os.path.join(twistedPath, "twisted", "python", "dist3.py")
with open(path) as dist3:
data = dist3.read()
code = compile(data, "dist3.py", "exec")
exec(code, modules)
testModules = modules["testModules"]
if not installed:
# Make sure checkout's code is used:
sys.path.insert(0, twistedPath)
from twisted.scripts import trial
# Run the tests.
sys.argv = ["run-python3-tests"] + extraArguments + testModules
trial.run()