forked from sigmavirus24/github3.py
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunittests.py
More file actions
executable file
·41 lines (35 loc) · 1.15 KB
/
unittests.py
File metadata and controls
executable file
·41 lines (35 loc) · 1.15 KB
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
#!/usr/bin/env python
# Originally co-authored by Jeff V Stein and Ian Cordasco for Todo.txt-python
# (http://git.io/todo.py)
import unittest
import sys
import os
import re
from getpass import getpass
try:
import readline
readline.parse_and_bind('tab: complete')
except ImportError:
pass
if __name__ == "__main__":
if not (os.environ.get('CI') or os.environ.get('TRAVIS')):
if hasattr(__builtins__, 'raw_input'):
prompt = raw_input
else:
prompt = input
user = pw = ''
while not user:
user = prompt('Enter GitHub username: ')
while not pw:
pw = getpass('Password for {0}: '.format(user))
os.environ['__USER'] = user
os.environ['__PASS'] = pw
if sys.version_info >= (2, 7):
suite = unittest.defaultTestLoader.discover("tests")
else:
names = os.listdir("tests")
regex = re.compile("(?!_+)\w+\.py$")
join = '.'.join
names = [join(['tests', f[:-3]]) for f in names if regex.match(f)]
suite = unittest.defaultTestLoader.loadTestsFromNames(names)
unittest.TextTestRunner(verbosity=1).run(suite)