Server IP : 66.29.132.122 / Your IP : 3.147.58.159 Web Server : LiteSpeed System : Linux business142.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64 User : admazpex ( 531) PHP Version : 7.2.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/self/root/proc/self/root/proc/thread-self/root/proc/thread-self/root/proc/self/root/proc/self/root/opt/cloudlinux/venv/lib64/python3.11/site-packages/tap/tests/ |
Upload File : |
import argparse import os from unittest import mock from tap.loader import Loader from tap.main import build_suite, get_status, main, main_module, parse_args from tap.tests import TestCase class TestMain(TestCase): """Tests for tap.main""" def test_exits_with_error(self): """The main function returns an error status if there were failures.""" argv = ["/bin/fake", "fake.tap"] stream = open(os.devnull, "w") status = main(argv, stream=stream) self.assertEqual(1, status) def test_get_successful_status(self): result = mock.Mock() result.wasSuccessful.return_value = True self.assertEqual(0, get_status(result)) @mock.patch.object(Loader, "load_suite_from_stdin") def test_build_suite_from_stdin(self, load_suite_from_stdin): args = mock.Mock() args.files = [] expected_suite = mock.Mock() load_suite_from_stdin.return_value = expected_suite suite = build_suite(args) self.assertEqual(expected_suite, suite) @mock.patch.object(Loader, "load_suite_from_stdin") def test_build_suite_from_stdin_dash(self, load_suite_from_stdin): argv = ["/bin/fake", "-"] args = parse_args(argv) expected_suite = mock.Mock() load_suite_from_stdin.return_value = expected_suite suite = build_suite(args) self.assertEqual(expected_suite, suite) @mock.patch("tap.main.sys.stdin") @mock.patch("tap.main.sys.exit") @mock.patch.object(argparse.ArgumentParser, "print_help") def test_when_no_pipe_to_stdin(self, print_help, sys_exit, mock_stdin): argv = ["/bin/fake"] mock_stdin.isatty = mock.Mock(return_value=True) parse_args(argv) self.assertTrue(print_help.called) self.assertTrue(sys_exit.called) class TestMainModule(TestCase): @mock.patch("tap.main.unittest") def test_main_set_to_stream(self, mock_unittest): main_module() mock_unittest.main.called