45 BASEDIR = os.path.dirname(os.path.abspath(__file__))
46 sys.path.append(BASEDIR)
57 func = self.COMMANDS.get(tuple(sorted(list(cmds))))
59 raise Exception(
"Unknown command '%s'" % cmds)
64 self.
COMMANDS[tuple(sorted(list(cmds)))] = func
68 if args[
'--testserver']
is None:
69 from django.core.management
import execute_from_command_line
70 from threading
import Thread
74 os.environ.setdefault(
"DJANGO_SETTINGS_MODULE",
"wi.settings")
75 from django.conf
import settings
78 settings.CAPTCHA =
False
81 server = Thread(target=execute_from_command_line, args=([[__file__,
'runserver',
'--noreload']]))
88 tests.TEST_SERVER = args[
'--testserver']
91 from unittest
import TestLoader, TextTestRunner
92 if args[
'--testfiles']
is None:
93 print(
'Test file not specified.')
94 test_files =
'*test.py'
96 test_files = args[
'--testfiles']
98 print(
'Running tests: ' + test_files)
99 tests = TestLoader().discover(os.path.join(BASEDIR,
'wi',
'tests'), test_files)
102 with open(os.path.join(os.path.dirname(__file__),
'wi',
'tests.log').replace(
'\\',
'/'),
'w')
as f:
103 f.write(
'Test run ' + str(datetime.datetime.now()) +
'\n\n')
104 testResults = TextTestRunner(stream=f, verbosity=2).run(tests)
105 print(
'Tests finished. Errors: ' + str(len(testResults.errors) + len(testResults.failures)) +
'.')
107 Commands.set_command(runtest_wi,
'runtest',
'wi')
110 if __name__ ==
'__main__':
111 options = docopt.docopt(__doc__, help=
True)
112 command, arguments = [], {}
113 for arg, val
in options.iteritems():
114 if arg[0] ==
'-' or arg[0].isupper():
118 func = Commands.get_command(command)