Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create lint_python.yml #23

Merged
merged 11 commits into from
May 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/lint_python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: lint_python
on: [pull_request, push]
jobs:
lint_python:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- run: pip install bandit black codespell flake8 isort mypy pytest pyupgrade safety
- run: bandit --recursive .
- run: black --check .
- run: codespell --quiet-level=2 --skip="*.tap" # --ignore-words-list=""
- run: flake8 . --max-line-length=88 --show-source --statistics
- run: isort --check-only --profile black . || true
- run: pip install junit_xml yamlish
- run: mypy --ignore-missing-imports .
- run: pytest . || true
- run: pytest --doctest-modules . || true
- run: shopt -s globstar && pyupgrade --py36-plus **/*.py
- run: safety check
- run: |
for FILENAME in test-eslint1 test-eslint2 test-eslint3 test test2 test3; do
echo "Testing ${FILENAME}..."
python tap2junit/tap13.py
python -m tap2junit -i "test/fixtures/${FILENAME}.tap" -o "test/output/${FILENAME}.xml"
cat "test/output/${FILENAME}.xml"
done
2 changes: 1 addition & 1 deletion tap2junit/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def map_yaml_to_junit(test):
err_code = yaml.get("exitcode", 0)
err_severity = yaml.get("severity", "")
err_output = yaml.get("stack", "")
error_message = "{} ({})".format(err_severity, err_code)
error_message = f"{err_severity} ({err_code})"
if err_code < 0 or err_severity == "crashed":
t.add_error_info(error_message, err_output, err_code)
else:
Expand Down
22 changes: 5 additions & 17 deletions tap2junit/tap13.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,12 @@
#
# Author: Josef Skladanka <jskladan@redhat.com>

from __future__ import print_function

import io
import re

import yamlish

try:
from StringIO import StringIO
except ImportError:
from io import StringIO


try:
basestring
except NameError:
basestring = str


RE_VERSION = re.compile(r"^\s*TAP version 13\s*$")
RE_PLAN = re.compile(
r"^\s*(?P<start>\d+)\.\.(?P<end>\d+)\s*(#\s*(?P<explanation>.*))?\s*$"
Expand All @@ -48,7 +36,7 @@
RE_YAMLISH_END = re.compile(r"^\s*\.\.\.\s*$")


class Test(object):
class Test:
def __init__(self, result, id, description=None, directive=None, comment=None):
self.result = result
self.id = id
Expand All @@ -63,7 +51,7 @@ def __init__(self, result, id, description=None, directive=None, comment=None):
self.diagnostics = []


class TAP13(object):
class TAP13:
def __init__(self):
self.tests = []
self.__tests_counter = 0
Expand Down Expand Up @@ -167,8 +155,8 @@ def _parse(self, source):
)

def parse(self, source):
if isinstance(source, basestring):
self._parse(StringIO(source))
if isinstance(source, str):
self._parse(io.StringIO(source))
elif hasattr(source, "__iter__"):
self._parse(source)

Expand Down