summaryrefslogtreecommitdiff
path: root/test/test.py
diff options
context:
space:
mode:
authorjvoisin2015-12-30 13:12:39 +0100
committerjvoisin2015-12-30 15:11:37 +0100
commit3ac3f353c64d406aa2fa46c5c9841346408e1e01 (patch)
tree562f27ff88253c693d4adc3acfe82693737c78a4 /test/test.py
parentb9d66ed2e07d0a40161c88d0ba52d59ac601c76e (diff)
Hopefully make test suite work once copied out of the build tree
This should fix https://labs.riseup.net/code/issues/10065
Diffstat (limited to 'test/test.py')
-rw-r--r--test/test.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/test/test.py b/test/test.py
index 3f259a7..fbbdcf4 100644
--- a/test/test.py
+++ b/test/test.py
@@ -15,8 +15,6 @@ import sys
15import tempfile 15import tempfile
16import unittest 16import unittest
17 17
18IS_LOCAL = True
19
20VERBOSITY = 15 18VERBOSITY = 15
21 19
22clean = glob.glob('clean*') 20clean = glob.glob('clean*')
@@ -80,10 +78,9 @@ def run_all_tests():
80 """ 78 """
81 This method will run all tests, both for cli and lib. 79 This method will run all tests, both for cli and lib.
82 The imports of clitest and libtest are done here because 80 The imports of clitest and libtest are done here because
83 of dependencie on the IS_LOCAL variable. 81 we're modifying the PATH (technically, it's two path:
84 82 the one used to spawn the `mat` process, and the one for Python import)
85 If set to true, the tests will be done on the _local_ instance 83 in the main function.
86 of MAT, else, on the _system-wide_ one.
87 """ 84 """
88 import clitest 85 import clitest
89 import libtest 86 import libtest
@@ -93,6 +90,14 @@ def run_all_tests():
93 90
94 return unittest.TextTestRunner(verbosity=VERBOSITY).run(SUITE).wasSuccessful() 91 return unittest.TextTestRunner(verbosity=VERBOSITY).run(SUITE).wasSuccessful()
95 92
93def set_local():
94 ''' Monkey patch pathes to run the testsuite on the _local_
95 version of MAT. See `run_all_tests` for more information about
96 what pathes we're changing and why.
97 '''
98 os.environ['PATH'] = '..:' + os.environ['PATH']
99 sys.path.append('..')
100
96if __name__ == '__main__': 101if __name__ == '__main__':
97 import argparse 102 import argparse
98 103
@@ -100,7 +105,7 @@ if __name__ == '__main__':
100 parser.add_argument('-s', '--system', action='store_true', 105 parser.add_argument('-s', '--system', action='store_true',
101 help='Test the system-wide version of mat') 106 help='Test the system-wide version of mat')
102 107
103 if parser.parse_args().system is True: 108 if parser.parse_args().system is False:
104 IS_LOCAL = False 109 set_local()
105 110
106 sys.exit(run_all_tests() is False) 111 sys.exit(run_all_tests() is False)