From 8fb44eba5bb9862de5fcc6c785eb6f21ecbd0aea Mon Sep 17 00:00:00 2001 From: Andy Hayden Date: Thu, 30 May 2019 13:40:40 -0700 Subject: chore: refactor python tests to use unittest (#2414) Move every test to a method on DenoTestCase. test.py is a single TestSuite of every TestCase. Add a Spawn context manager for http_server, this is explicitly used where it's needed. Each python test file can now be run independently without needing to manually run http_server. Add --help and consistent flags using argparse for each python test, including --failfast. Use ColorTextTestRunner so that '... ok' is green. --- tools/util_test.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'tools/util_test.py') diff --git a/tools/util_test.py b/tools/util_test.py index 7d189797d..5db50e420 100755 --- a/tools/util_test.py +++ b/tools/util_test.py @@ -1,18 +1,19 @@ # Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. +import os import sys -import unittest from util import ( + DenoTestCase, pattern_match, parse_exit_code, shell_quote_win, parse_wrk_output, root_path, + test_main, ) -import os -class TestUtil(unittest.TestCase): +class TestUtil(DenoTestCase): def test_pattern_match(self): # yapf: disable fixtures = [("foobarbaz", "foobarbaz", True), @@ -68,12 +69,5 @@ class TestUtil(unittest.TestCase): assert stats3['max_latency'] == 1630.0 -def util_test(): - suite = unittest.TestLoader().loadTestsFromTestCase(TestUtil) - result = unittest.TextTestRunner(verbosity=2).run(suite) - if not result.wasSuccessful(): - sys.exit(1) - - if __name__ == '__main__': - util_test() + test_main() -- cgit v1.2.3