FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

added tox.ini support, improved unittests · python-webuntis/python-webuntis@67a98b4 · GitHub

Repository navigation

Commit 67a98b4

Browse files
committed
added tox.ini support, improved unittests
1 parent f1fe2b9 commit 67a98b4

3 files changed

Lines changed: 35 additions & 29 deletions

File tree

‎.gitignore‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
__pycache__
1+
*.egg
2+
*.egg-info
23
*.pyc
3-
docs/_build/
4-
dist/
54
.coverage
5+
.tox
6+
__pycache__
7+
dist
8+
dist/
9+
docs/_build/
10+
env
11+
env*
12+
fabfile*
613
htmlcov

‎tox.ini‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[tox]
2+
envlist=py27,py32,pypy
3+
4+
[testenv]
5+
commands=python run-tests.py
6+
deps=mock

‎webuntis/tests/__init__.py‎

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ def test_optionparsers_credentials(self):
340340
(void_user_and_pwd, {}),
341341
(user_and_void_pwd, {}),
342342
(void_user_and_void_pwd, {}),
343-
(dict(user_and_pwd.items() + void_jsessionid.items()), user_and_pwd)
343+
(dict(user_and_pwd, **void_jsessionid), user_and_pwd)
344344
]
345345

346346
for parser_input, expected_output in tests:
@@ -466,33 +466,26 @@ def test_loggedout(self):
466466
self.assertFalse('jsessionid' in creds)
467467
self.assertRaises(webuntis.errors.AuthError, self.session.klassen)
468468

469+
class test_cases(object):
470+
offline = WebUntisOfflineTests
471+
online = WebUntisRemoteTests
472+
473+
def mk_suite(tests):
474+
loader = unittest.TestLoader()
475+
suite = unittest.TestSuite()
476+
for test in tests:
477+
suite.addTest(loader.loadTestsFromName(test, test_cases))
478+
479+
return suite
480+
481+
default_suite = ['offline']
482+
469483

470484
def main():
471-
try:
472-
raw_input # check if we have python2
473-
except NameError:
474-
prompt = input
475-
else:
476-
prompt = raw_input
477-
478-
def load(test):
479-
suite = unittest.TestLoader().loadTestsFromTestCase(test)
480-
unittest.TextTestRunner(verbosity=2).run(suite)
481-
482-
tests = [WebUntisOfflineTests, WebUntisRemoteTests]
483-
484-
if len(sys.argv) == 1:
485-
print('ERROR: No tests specified.\nAdd a number to the command-line arguments to execute the test:\n')
486-
for i, test in enumerate(tests):
487-
print('###{}: {}'.format(i, test.__name__))
488-
print(test.__doc__)
489-
exit(1)
490-
491-
checked_tests = [tests[int(x)] for x in sys.argv[1:]]
492-
493-
for test in checked_tests:
494-
prompt('Hit enter to continue.')
495-
load(test)
485+
suite = mk_suite(sys.argv[1:] or default_suite)
486+
result = unittest.TextTestRunner(verbosity=2).run(suite)
487+
if result.errors or result.failures:
488+
sys.exit(1)
496489

497490
if __name__ == '__main__':
498491
main()

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL