mirror of
https://github.com/denoland/deno.git
synced 2025-09-28 13:14:48 +00:00
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.
This commit is contained in:
parent
1540b36ce7
commit
8fb44eba5b
17 changed files with 548 additions and 603 deletions
|
@ -1,14 +1,15 @@
|
|||
# Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
from setup import gn_string, read_gn_args, write_gn_args
|
||||
from shutil import rmtree
|
||||
from tempfile import mktemp
|
||||
|
||||
from util import DenoTestCase, test_main
|
||||
|
||||
class TestSetup(unittest.TestCase):
|
||||
|
||||
class TestSetup(DenoTestCase):
|
||||
def test_gn_string(self):
|
||||
assert '"abc"' == gn_string('abc')
|
||||
assert '"foo\\$bar\\"baz"' == gn_string('foo$bar"baz')
|
||||
|
@ -61,12 +62,5 @@ class TestSetup(unittest.TestCase):
|
|||
rmtree(d)
|
||||
|
||||
|
||||
def setup_test():
|
||||
suite = unittest.TestLoader().loadTestsFromTestCase(TestSetup)
|
||||
result = unittest.TextTestRunner(verbosity=2).run(suite)
|
||||
if not result.wasSuccessful():
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
setup_test()
|
||||
test_main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue