404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@3.145.79.214: ~ $
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

Filemanager

Name Type Size Permission Actions
__pycache__ Folder 0755
__init__.py File 71 B 0644
factory.py File 1.05 KB 0644
run.py File 456 B 0644
test_adapter.py File 1.84 KB 0644
test_directive.py File 1.2 KB 0644
test_formatter.py File 601 B 0644
test_line.py File 1.2 KB 0644
test_loader.py File 3.66 KB 0644
test_main.py File 1.96 KB 0644
test_parser.py File 16.24 KB 0644
test_result.py File 3.4 KB 0644
test_rules.py File 2.81 KB 0644
test_runner.py File 3.32 KB 0644
test_tracker.py File 10.91 KB 0644
testcase.py File 222 B 0644