-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpeeptests
executable file
·38 lines (26 loc) · 1.05 KB
/
peeptests
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
#!/usr/bin/env python
import optparse
import peep
import sys
if sys.hexversion >= 0x02070000:
import unittest
else:
# Require unittest2 on Python 2.6 for its test discovery
import unittest2 as unittest
def discover(path, pattern):
return unittest.defaultTestLoader.discover(path, pattern)
def test(tests, verbosity):
return unittest.TextTestRunner(verbosity=verbosity).run(tests)
def main():
parser = optparse.OptionParser(usage="Usage: %prog [options]")
parser.add_option("-d", "--dir", type="str", default=".",
help="Root path to search for tests")
parser.add_option("-p", "--pattern", type="str", default="*_test.py",
help="Filename path for test discovery")
parser.add_option("-v", "--verbosity", type="int", default="2",
help="TestRunner verbosity")
(options, _) = parser.parse_args()
peep.call_on_change(lambda: test(discover(options.dir, options.pattern),
options.verbosity))
if __name__ == "__main__":
main()