2017-10-19 20:37:39 +02:00
|
|
|
#!/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(
|
2021-06-07 11:49:21 +02:00
|
|
|
os.path.join(os.path.dirname(inspect.getfile(inspect.currentframe())), '..')
|
|
|
|
)
|
2017-10-19 20:37:39 +02:00
|
|
|
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__":
|
2018-08-14 10:34:13 +02:00
|
|
|
os.chdir(os.path.dirname(__file__))
|
|
|
|
|
2024-05-02 14:08:28 +02:00
|
|
|
import argparse
|
2024-05-08 16:26:46 +02:00
|
|
|
from testcommon import parse_args_for_test
|
2024-05-02 14:08:28 +02:00
|
|
|
|
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
parser.add_argument(
|
2021-06-07 11:49:21 +02:00
|
|
|
"-v",
|
|
|
|
"--verbose",
|
|
|
|
action="store_true",
|
|
|
|
default=False,
|
|
|
|
help="Spew out even more information than normal",
|
|
|
|
)
|
2024-05-08 16:26:46 +02:00
|
|
|
parse_args_for_test(parser, sys.argv)
|
2017-10-19 20:37:39 +02:00
|
|
|
|
|
|
|
newSuite = unittest.TestSuite()
|
|
|
|
newSuite.addTest(unittest.makeSuite(ExceptionTest))
|
2017-10-20 11:51:59 +02:00
|
|
|
unittest.main(failfast=False)
|