diff options
author | Andy Hayden <andyhayden1@gmail.com> | 2019-05-30 13:40:40 -0700 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2019-05-30 16:40:40 -0400 |
commit | 8fb44eba5bb9862de5fcc6c785eb6f21ecbd0aea (patch) | |
tree | 9c866283b36d8388af4fd0e72d2bf2da4b8b70e4 /tools/is_tty_test.py | |
parent | 1540b36ce7a4740f4a87c564becca65ed8d97255 (diff) |
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.
Diffstat (limited to 'tools/is_tty_test.py')
-rwxr-xr-x | tools/is_tty_test.py | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/tools/is_tty_test.py b/tools/is_tty_test.py index 6f7509a8c..79267fdd5 100755 --- a/tools/is_tty_test.py +++ b/tools/is_tty_test.py @@ -1,27 +1,23 @@ #!/usr/bin/env python # Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. import os -import pty -import select import subprocess -from util import build_path, executable_suffix +import unittest from sys import stdin -from permission_prompt_test import tty_capture - -IS_TTY_TEST_TS = "tests/is_tty.ts" +from util import DenoTestCase, test_main, tty_capture -def is_tty_test(deno_exe): - cmd = [deno_exe, "run", IS_TTY_TEST_TS] - code, stdout, _ = tty_capture(cmd, b'') - assert code == 0 - assert str(stdin.isatty()).lower() in stdout +IS_TTY_TEST_TS = "tests/is_tty.ts" -def main(): - deno_exe = os.path.join(build_path(), "deno" + executable_suffix) - is_tty_test(deno_exe) +@unittest.skipIf(os.name == 'nt', "Unable to test tty on Windows") +class TestIsTty(DenoTestCase): + def test_is_tty(self): + cmd = [self.deno_exe, "run", IS_TTY_TEST_TS] + code, stdout, _ = tty_capture(cmd, b'') + assert code == 0 + assert str(stdin.isatty()).lower() in stdout if __name__ == "__main__": - main() + test_main() |