forked from Chrezm/TsuserverDR
-
Notifications
You must be signed in to change notification settings - Fork 3
/
test.py
62 lines (50 loc) · 2.05 KB
/
test.py
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# TsuserverDR, server software for Danganronpa Online based on tsuserver3,
# which is server software for Attorney Online.
#
# Copyright (C) 2016 argoneus <[email protected]> (original tsuserver3)
# (C) 2018-22 Chrezm/Iuvee <[email protected]> (further additions)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
Run a collection of unit and integration tests on TsuserverDR.
It does not create any active accessible servers, but instead just merely
simulates client connections and actions.
"""
import asyncio
import sys
import unittest
class NoSkipLogTextTestResult(unittest.TextTestResult):
# I dont want "s" in my log
def addSkip(self, test, reason):
super(unittest.TextTestResult, self).addSkip(test, reason)
if self.showAll:
self.stream.writeln("skipped {0!r}".format(reason))
elif self.dots:
self.stream.flush()
class NoSkipLogTextTestRunner(unittest.TextTestRunner):
resultclass = NoSkipLogTextTestResult
if __name__ == '__main__':
if len(sys.argv) > 1:
pattern = sys.argv[1]
else:
pattern = 'test*.py'
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
TEST_SUITE = unittest.TestLoader().discover('.', pattern=pattern)
tester = NoSkipLogTextTestRunner(verbosity=1, failfast=True)
results = tester.run(TEST_SUITE)
wrong = results.errors + results.failures
if wrong:
notification = 'TEST.PY FAILED'
raise AssertionError(notification)