-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.py
57 lines (49 loc) · 1.53 KB
/
test.py
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
from __future__ import print_function
"""
Run unit tests for minis
"""
import os, sys
from pathlib import Path
import pytest
def main():
# Make sure we look for minis here first.
path = Path(__file__).parent
print("Parent path: ", path)
sys.path.insert(0, str(path))
# Allow user to audit tests with --audit flag
import ephys.ephys_analysis
import ephys.tools
if '--audit' in sys.argv:
sys.argv.remove('--audit')
sys.argv.append('-s') # needed for cli-based user interaction
ephys.mini_analyses.AUDIT_TESTS = True
if '--tensor_flow_test' in sys.argv:
sys.argv.remove('--tensor_flow_test')
sys.argc.append('-s')
flags.append('ephys/tools/tests/test_tensorflow.py')
# generate test flags
flags = sys.argv[1:]
flags.append('-v')
tb = [flag for flag in flags if flag.startswith('--tb')]
if len(tb) == 0:
flags.append('--tb=short')
add_path = True
print("flags: ", flags)
for flag in flags:
pflag = Path(flag)
if pflag.is_dir() or pflag.is_file():
add_path = False
print("add path was set false")
break
if add_path:
flags.append('ephys/mini_analyses')
flags.append('ephys/ephys_analysis')
flags.append('ephys/psc_analysis')
print("flags: ", flags)
# ignore the an cache
# flags.append('--ignore=minis/somedir')
# Start tests.
print("Testing with flags: %s" % " ".join(flags))
pytest.main(flags)
if __name__ == '__main__':
main()