404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@18.118.26.128: ~ $
try:
    import yaml

    LOAD_YAML = True
except ImportError:  # pragma: no cover
    LOAD_YAML = False


class Line(object):
    """Base type for TAP data.

    TAP is a line based protocol. Thus, the most primitive type is a line.
    """

    @property
    def category(self):
        raise NotImplementedError


class Result(Line):
    """Information about an individual test line."""

    def __init__(
        self,
        ok,
        number=None,
        description="",
        directive=None,
        diagnostics=None,
        raw_yaml_block=None,
    ):
        self._ok = ok
        if number:
            self._number = int(number)
        else:
            # The number may be an empty string so explicitly set to None.
            self._number = None
        self._description = description
        self.directive = directive
        self.diagnostics = diagnostics
        self._yaml_block = raw_yaml_block

    @property
    def category(self):
        """:returns: ``test``"""
        return "test"

    @property
    def ok(self):
        """Get the ok status.

        :rtype: bool
        """
        return self._ok

    @property
    def number(self):
        """Get the test number.

        :rtype: int
        """
        return self._number

    @property
    def description(self):
        """Get the description."""
        return self._description

    @property
    def skip(self):
        """Check if this test was skipped.

        :rtype: bool
        """
        return self.directive.skip

    @property
    def todo(self):
        """Check if this test was a TODO.

        :rtype: bool
        """
        return self.directive.todo

    @property
    def yaml_block(self):
        """Lazy load a yaml_block.

        If yaml support is not available,
        there is an error in parsing the yaml block,
        or no yaml is associated with this result,
        ``None`` will be returned.

        :rtype: dict
        """
        if LOAD_YAML and self._yaml_block is not None:
            try:
                yaml_dict = yaml.load(self._yaml_block, Loader=yaml.SafeLoader)
                return yaml_dict
            except yaml.error.YAMLError:
                print("Error parsing yaml block. Check formatting.")
        return None

    def __str__(self):
        is_not = ""
        if not self.ok:
            is_not = "not "
        directive = ""
        if self.directive is not None and self.directive.text:
            directive = " # {0}".format(self.directive.text)
        diagnostics = ""
        if self.diagnostics is not None:
            diagnostics = "\n" + self.diagnostics.rstrip()
        return "{0}ok {1} {2}{3}{4}".format(
            is_not, self.number, self.description, directive, diagnostics
        )


class Plan(Line):
    """A plan line to indicate how many tests to expect."""

    def __init__(self, expected_tests, directive=None):
        self._expected_tests = expected_tests
        self.directive = directive

    @property
    def category(self):
        """:returns: ``plan``"""
        return "plan"

    @property
    def expected_tests(self):
        """Get the number of expected tests.

        :rtype: int
        """
        return self._expected_tests

    @property
    def skip(self):
        """Check if this plan should skip the file.

        :rtype: bool
        """
        return self.directive.skip


class Diagnostic(Line):
    """A diagnostic line (i.e. anything starting with a hash)."""

    def __init__(self, text):
        self._text = text

    @property
    def category(self):
        """:returns: ``diagnostic``"""
        return "diagnostic"

    @property
    def text(self):
        """Get the text."""
        return self._text


class Bail(Line):
    """A bail out line (i.e. anything starting with 'Bail out!')."""

    def __init__(self, reason):
        self._reason = reason

    @property
    def category(self):
        """:returns: ``bail``"""
        return "bail"

    @property
    def reason(self):
        """Get the reason."""
        return self._reason


class Version(Line):
    """A version line (i.e. of the form 'TAP version 13')."""

    def __init__(self, version):
        self._version = version

    @property
    def category(self):
        """:returns: ``version``"""
        return "version"

    @property
    def version(self):
        """Get the version number.

        :rtype: int
        """
        return self._version


class Unknown(Line):
    """A line that represents something that is not a known TAP line.

    This exists for the purpose of a Null Object pattern.
    """

    @property
    def category(self):
        """:returns: ``unknown``"""
        return "unknown"

Filemanager

Name Type Size Permission Actions
__pycache__ Folder 0755
tests Folder 0755
__init__.py File 83 B 0644
__main__.py File 48 B 0644
adapter.py File 1.51 KB 0644
directive.py File 1.76 KB 0644
formatter.py File 762 B 0644
line.py File 4.62 KB 0644
loader.py File 2.88 KB 0644
main.py File 2.07 KB 0644
parser.py File 6.7 KB 0644
rules.py File 3.39 KB 0644
runner.py File 5.08 KB 0644
tracker.py File 7.43 KB 0644