diff --git a/.travis.yml b/.travis.yml index 10a6be6..e6c1210 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ env: - FILENAME=test2 - FILENAME=test3 install: pip install flake8 junit-xml yamlish -before_script: flake8 . --count --select=E9,F --show-source --statistics +before_script: flake8 . --max-line-length=88 script: - python tap2junit/tap13.py - python -m tap2junit -i test/fixtures/${FILENAME}.tap -o test/output/${FILENAME}.xml diff --git a/tap2junit/tap13.py b/tap2junit/tap13.py index 1a8f3ac..e05b710 100644 --- a/tap2junit/tap13.py +++ b/tap2junit/tap13.py @@ -1,5 +1,3 @@ -from __future__ import print_function - # Copyright 2019, Red Hat, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -39,7 +37,10 @@ r"^\s*(?P\d+)\.\.(?P\d+)\s*(#\s*(?P.*))?\s*$" ) RE_TEST_LINE = re.compile( - r"^\s*(?P(not\s+)?ok)\s*(?P\d+)?\s*(?P[^#]+)?\s*(#\s*(?PTODO|SKIP)?\s*(?P.+)?)?\s*$", + ( + r"^\s*(?P(not\s+)?ok)\s*(?P\d+)?\s*(?P[^#]+)" + r"?\s*(#\s*(?PTODO|SKIP)?\s*(?P.+)?)?\s*$" + ), re.IGNORECASE, ) RE_EXPLANATION = re.compile(r"^\s*#\s*(?P.+)?\s*$") @@ -124,7 +125,7 @@ def _parse(self, source): seek_plan = False # Stop processing if tests were found before the plan - # if plan is at the end, it must be the last line -> stop processing + # if plan is at the end, it must be last line -> stop processing if self.__tests_counter > 0: break @@ -138,8 +139,8 @@ def _parse(self, source): t_attrs["id"] = int(t_attrs["id"]) if t_attrs["id"] < self.__tests_counter: raise ValueError("Descending test id on line: %r" % line) - # according to TAP13 specs, missing tests must be handled as 'not ok' - # here we add the missing tests in sequence + # according to TAP13 specs, missing tests must be handled as + # 'not ok' so here we add the missing tests in sequence while t_attrs["id"] > self.__tests_counter: self.tests.append( Test( @@ -173,7 +174,7 @@ def parse(self, source): if __name__ == "__main__": - input = """ + text = """ TAP version 13 ok 1 - Input file opened not ok 2 - First line of the input valid @@ -208,7 +209,7 @@ def parse(self, source): 1..6 """ t = TAP13() - t.parse(input) + t.parse(text) import pprint