Skip to content

Commit

Permalink
Create lint_python.yml (#23)
Browse files Browse the repository at this point in the history
* Create lint_python.yml

* Update lint_python.yml

* Update lint_python.yml

* pyupgrade --py36-plus __main__.py

* Update tap13.py

* Update lint_python.yml

* Drop the {}

* Double quotes

* Update lint_python.yml

* Update lint_python.yml

* Update lint_python.yml
  • Loading branch information
cclauss authored May 8, 2021
1 parent dab991d commit f7ed9be
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 18 deletions.
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

0 comments on commit f7ed9be

Please sign in to comment.