404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@3.133.149.244: ~ $
import contextlib
import os
import unittest
import unittest.case

from tap.runner import TAPTestResult
from tap.tests import TestCase
from tap.tracker import Tracker


class FakeTestCase(unittest.TestCase):
    def runTest(self):
        pass

    @contextlib.contextmanager
    def subTest(self, *args, **kwargs):
        try:
            self._subtest = unittest.case._SubTest(self, object(), {})
            yield
        finally:
            self._subtest = None

    def __call__(self, result):
        pass


class TestTAPTestResult(TestCase):
    @classmethod
    def _make_one(cls):
        # Yep, the stream is not being closed.
        stream = open(os.devnull, "w")
        result = TAPTestResult(stream, False, 0)
        result.tracker = Tracker()
        return result

    def test_adds_error(self):
        result = self._make_one()
        # Python 3 does some extra testing in unittest on exceptions so fake
        # the cause as if it were raised.
        ex = Exception()
        ex.__cause__ = None
        result.addError(FakeTestCase(), (None, ex, None))
        self.assertEqual(len(result.tracker._test_cases["FakeTestCase"]), 1)

    def test_adds_failure(self):
        result = self._make_one()
        # Python 3 does some extra testing in unittest on exceptions so fake
        # the cause as if it were raised.
        ex = Exception()
        ex.__cause__ = None
        result.addFailure(FakeTestCase(), (None, ex, None))
        self.assertEqual(len(result.tracker._test_cases["FakeTestCase"]), 1)

    def test_adds_success(self):
        result = self._make_one()
        result.addSuccess(FakeTestCase())
        self.assertEqual(len(result.tracker._test_cases["FakeTestCase"]), 1)

    def test_adds_skip(self):
        result = self._make_one()
        result.addSkip(FakeTestCase(), "a reason")
        self.assertEqual(len(result.tracker._test_cases["FakeTestCase"]), 1)

    def test_adds_expected_failure(self):
        exc = self.factory.make_exc()
        result = self._make_one()
        result.addExpectedFailure(FakeTestCase(), exc)
        line = result.tracker._test_cases["FakeTestCase"][0]
        self.assertFalse(line.ok)
        self.assertEqual(line.directive.text, "TODO {}".format("(expected failure)"))

    def test_adds_unexpected_success(self):
        result = self._make_one()
        result.addUnexpectedSuccess(FakeTestCase())
        line = result.tracker._test_cases["FakeTestCase"][0]
        self.assertTrue(line.ok)
        self.assertEqual(line.directive.text, "TODO {}".format("(unexpected success)"))

    def test_adds_subtest_success(self):
        """Test that the runner handles subtest success results."""
        result = self._make_one()
        test = FakeTestCase()
        with test.subTest():
            result.addSubTest(test, test._subtest, None)
        line = result.tracker._test_cases["FakeTestCase"][0]
        self.assertTrue(line.ok)

    def test_adds_subtest_failure(self):
        """Test that the runner handles subtest failure results."""
        result = self._make_one()
        # Python 3 does some extra testing in unittest on exceptions so fake
        # the cause as if it were raised.
        ex = Exception()
        ex.__cause__ = None
        test = FakeTestCase()
        with test.subTest():
            result.addSubTest(test, test._subtest, (ex.__class__, ex, None))
        line = result.tracker._test_cases["FakeTestCase"][0]
        self.assertFalse(line.ok)

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