mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-04 22:40:29 +03:00
Refactor TestCase files into python modules
Convert all TestCase files into standard python modules to be run and discovered by unittest.
This commit is contained in:
parent
4d6682bc70
commit
7ff32bc4b0
34 changed files with 471 additions and 1260 deletions
|
|
@ -1,74 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
# http://www.drdobbs.com/testing/unit-testing-with-python/240165163
|
||||
|
||||
import inspect
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
localmodule = os.path.realpath(
|
||||
os.path.join(os.path.dirname(inspect.getfile(inspect.currentframe())), '..')
|
||||
)
|
||||
print('localmodule: ' + localmodule)
|
||||
if localmodule not in sys.path:
|
||||
sys.path.insert(0, localmodule)
|
||||
|
||||
import fdroidserver.common
|
||||
import fdroidserver.exception
|
||||
|
||||
|
||||
class ExceptionTest(unittest.TestCase):
|
||||
'''fdroidserver/exception.py'''
|
||||
|
||||
def test_FDroidException(self):
|
||||
try:
|
||||
raise fdroidserver.exception.FDroidException()
|
||||
except fdroidserver.exception.FDroidException as e:
|
||||
str(e)
|
||||
|
||||
try:
|
||||
raise fdroidserver.exception.FDroidException(9)
|
||||
except fdroidserver.exception.FDroidException as e:
|
||||
str(e)
|
||||
|
||||
try:
|
||||
raise fdroidserver.exception.FDroidException(-123.12234)
|
||||
except fdroidserver.exception.FDroidException as e:
|
||||
str(e)
|
||||
|
||||
try:
|
||||
raise fdroidserver.exception.FDroidException("this is a string")
|
||||
except fdroidserver.exception.FDroidException as e:
|
||||
str(e)
|
||||
|
||||
try:
|
||||
raise fdroidserver.exception.FDroidException(['one', 'two', 'three'])
|
||||
except fdroidserver.exception.FDroidException as e:
|
||||
str(e)
|
||||
|
||||
try:
|
||||
raise fdroidserver.exception.FDroidException(('one', 'two', 'three'))
|
||||
except fdroidserver.exception.FDroidException as e:
|
||||
str(e)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
os.chdir(os.path.dirname(__file__))
|
||||
|
||||
import argparse
|
||||
from testcommon import parse_args_for_test
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
"-v",
|
||||
"--verbose",
|
||||
action="store_true",
|
||||
default=False,
|
||||
help="Spew out even more information than normal",
|
||||
)
|
||||
parse_args_for_test(parser, sys.argv)
|
||||
|
||||
newSuite = unittest.TestSuite()
|
||||
newSuite.addTest(unittest.makeSuite(ExceptionTest))
|
||||
unittest.main(failfast=False)
|
||||
Loading…
Add table
Add a link
Reference in a new issue