GRAYBYTE WORDPRESS FILE MANAGER9703

Server IP : 198.54.121.189 / Your IP : 216.73.216.34
System : Linux premium69.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
PHP Version : 7.4.33
Disable Function : NONE
cURL : ON | WGET : ON | Sudo : OFF | Pkexec : OFF
Directory : /lib64/python2.7/unittest/
Upload Files :
Current_dir [ Not Writeable ] Document_root [ Writeable ]

Command :


Current File : /lib64/python2.7/unittest//result.py
"""Test result object"""

import os
import sys
import traceback

from StringIO import StringIO

from . import util
from functools import wraps

__unittest = True

def failfast(method):
    @wraps(method)
    def inner(self, *args, **kw):
        if getattr(self, 'failfast', False):
            self.stop()
        return method(self, *args, **kw)
    return inner

STDOUT_LINE = '\nStdout:\n%s'
STDERR_LINE = '\nStderr:\n%s'


class TestResult(object):
    """Holder for test result information.

    Test results are automatically managed by the TestCase and TestSuite
    classes, and do not need to be explicitly manipulated by writers of tests.

    Each instance holds the total number of tests run, and collections of
    failures and errors that occurred among those test runs. The collections
    contain tuples of (testcase, exceptioninfo), where exceptioninfo is the
    formatted traceback of the error that occurred.
    """
    _previousTestClass = None
    _testRunEntered = False
    _moduleSetUpFailed = False
    def __init__(self, stream=None, descriptions=None, verbosity=None):
        self.failfast = False
        self.failures = []
        self.errors = []
        self.testsRun = 0
        self.skipped = []
        self.expectedFailures = []
        self.unexpectedSuccesses = []
        self.shouldStop = False
        self.buffer = False
        self._stdout_buffer = None
        self._stderr_buffer = None
        self._original_stdout = sys.stdout
        self._original_stderr = sys.stderr
        self._mirrorOutput = False

    def printErrors(self):
        "Called by TestRunner after test run"

    def startTest(self, test):
        "Called when the given test is about to be run"
        self.testsRun += 1
        self._mirrorOutput = False
        self._setupStdout()

    def _setupStdout(self):
        if self.buffer:
            if self._stderr_buffer is None:
                self._stderr_buffer = StringIO()
                self._stdout_buffer = StringIO()
            sys.stdout = self._stdout_buffer
            sys.stderr = self._stderr_buffer

    def startTestRun(self):
        """Called once before any tests are executed.

        See startTest for a method called before each test.
        """

    def stopTest(self, test):
        """Called when the given test has been run"""
        self._restoreStdout()
        self._mirrorOutput = False

    def _restoreStdout(self):
        if self.buffer:
            if self._mirrorOutput:
                output = sys.stdout.getvalue()
                error = sys.stderr.getvalue()
                if output:
                    if not output.endswith('\n'):
                        output += '\n'
                    self._original_stdout.write(STDOUT_LINE % output)
                if error:
                    if not error.endswith('\n'):
                        error += '\n'
                    self._original_stderr.write(STDERR_LINE % error)

            sys.stdout = self._original_stdout
            sys.stderr = self._original_stderr
            self._stdout_buffer.seek(0)
            self._stdout_buffer.truncate()
            self._stderr_buffer.seek(0)
            self._stderr_buffer.truncate()

    def stopTestRun(self):
        """Called once after all tests are executed.

        See stopTest for a method called after each test.
        """

    @failfast
    def addError(self, test, err):
        """Called when an error has occurred. 'err' is a tuple of values as
        returned by sys.exc_info().
        """
        self.errors.append((test, self._exc_info_to_string(err, test)))
        self._mirrorOutput = True

    @failfast
    def addFailure(self, test, err):
        """Called when an error has occurred. 'err' is a tuple of values as
        returned by sys.exc_info()."""
        self.failures.append((test, self._exc_info_to_string(err, test)))
        self._mirrorOutput = True

    def addSuccess(self, test):
        "Called when a test has completed successfully"
        pass

    def addSkip(self, test, reason):
        """Called when a test is skipped."""
        self.skipped.append((test, reason))

    def addExpectedFailure(self, test, err):
        """Called when an expected failure/error occurred."""
        self.expectedFailures.append(
            (test, self._exc_info_to_string(err, test)))

    @failfast
    def addUnexpectedSuccess(self, test):
        """Called when a test was expected to fail, but succeed."""
        self.unexpectedSuccesses.append(test)

    def wasSuccessful(self):
        "Tells whether or not this result was a success"
        return len(self.failures) == len(self.errors) == 0

    def stop(self):
        "Indicates that the tests should be aborted"
        self.shouldStop = True

    def _exc_info_to_string(self, err, test):
        """Converts a sys.exc_info()-style tuple of values into a string."""
        exctype, value, tb = err
        # Skip test runner traceback levels
        while tb and self._is_relevant_tb_level(tb):
            tb = tb.tb_next

        if exctype is test.failureException:
            # Skip assert*() traceback levels
            length = self._count_relevant_tb_levels(tb)
            msgLines = traceback.format_exception(exctype, value, tb, length)
        else:
            msgLines = traceback.format_exception(exctype, value, tb)

        if self.buffer:
            output = sys.stdout.getvalue()
            error = sys.stderr.getvalue()
            if output:
                if not output.endswith('\n'):
                    output += '\n'
                msgLines.append(STDOUT_LINE % output)
            if error:
                if not error.endswith('\n'):
                    error += '\n'
                msgLines.append(STDERR_LINE % error)
        return ''.join(msgLines)


    def _is_relevant_tb_level(self, tb):
        return '__unittest' in tb.tb_frame.f_globals

    def _count_relevant_tb_levels(self, tb):
        length = 0
        while tb and not self._is_relevant_tb_level(tb):
            length += 1
            tb = tb.tb_next
        return length

    def __repr__(self):
        return ("<%s run=%i errors=%i failures=%i>" %
               (util.strclass(self.__class__), self.testsRun, len(self.errors),
                len(self.failures)))

[ Back ]
Name
Size
Last Modified
Owner / Group
Permissions
Options
..
--
June 15 2024 08:34:30
root / root
0755
test
--
June 15 2024 08:34:30
root / root
0755
__init__.py
2.717 KB
April 10 2024 04:58:35
root / root
0644
__init__.pyc
2.966 KB
April 10 2024 04:58:46
root / root
0644
__init__.pyo
2.966 KB
April 10 2024 04:58:46
root / root
0644
__main__.py
0.232 KB
April 10 2024 04:58:35
root / root
0644
__main__.pyc
0.477 KB
April 10 2024 04:58:46
root / root
0644
__main__.pyo
0.477 KB
April 10 2024 04:58:46
root / root
0644
case.py
42.953 KB
April 10 2024 04:58:35
root / root
0644
case.pyc
40.701 KB
April 10 2024 04:58:46
root / root
0644
case.pyo
40.701 KB
April 10 2024 04:58:46
root / root
0644
loader.py
13.181 KB
April 10 2024 04:58:35
root / root
0644
loader.pyc
11.109 KB
April 10 2024 04:58:46
root / root
0644
loader.pyo
10.973 KB
April 10 2024 04:58:44
root / root
0644
main.py
8.87 KB
April 10 2024 04:58:35
root / root
0644
main.pyc
7.809 KB
April 10 2024 04:58:46
root / root
0644
main.pyo
7.809 KB
April 10 2024 04:58:46
root / root
0644
result.py
6.16 KB
April 10 2024 04:58:35
root / root
0644
result.pyc
7.739 KB
April 10 2024 04:58:46
root / root
0644
result.pyo
7.739 KB
April 10 2024 04:58:46
root / root
0644
runner.py
6.38 KB
April 10 2024 04:58:35
root / root
0644
runner.pyc
7.452 KB
April 10 2024 04:58:46
root / root
0644
runner.pyo
7.452 KB
April 10 2024 04:58:46
root / root
0644
signals.py
2.354 KB
April 10 2024 04:58:35
root / root
0644
signals.pyc
2.716 KB
April 10 2024 04:58:46
root / root
0644
signals.pyo
2.716 KB
April 10 2024 04:58:46
root / root
0644
suite.py
9.579 KB
April 10 2024 04:58:35
root / root
0644
suite.pyc
10.291 KB
April 10 2024 04:58:46
root / root
0644
suite.pyo
10.291 KB
April 10 2024 04:58:46
root / root
0644
util.py
4.498 KB
April 10 2024 04:58:35
root / root
0644
util.pyc
4.412 KB
April 10 2024 04:58:46
root / root
0644
util.pyo
4.412 KB
April 10 2024 04:58:46
root / root
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025
CONTACT ME
Static GIF