From fbd95162279a1aca3f4f2251edd09d6bac16f43d Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Tue, 20 Apr 2021 17:16:55 +0100 Subject: python: Mark rawstrings as such Resolves the following warnings in Python 3.6+: DeprecationWarning: invalid escape sequence \! match = re.match("Bail out\!(?:\s*(.*))?\n", line) Signed-off-by: Stephen Finucane --- python/subunit/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/python/subunit/__init__.py b/python/subunit/__init__.py index 17a970a..becbdac 100644 --- a/python/subunit/__init__.py +++ b/python/subunit/__init__.py @@ -1033,7 +1033,7 @@ def TAP2SubUnit(tap, output_stream): file_name=file_name, runnable=False) for line in tap: if state == BEFORE_PLAN: - match = re.match("(\d+)\.\.(\d+)\s*(?:\#\s+(.*))?\n", line) + match = re.match(r"(\d+)\.\.(\d+)\s*(?:\#\s+(.*))?\n", line) if match: state = AFTER_PLAN _, plan_stop, comment = match.groups() @@ -1046,7 +1046,7 @@ def TAP2SubUnit(tap, output_stream): file_name='tap comment') continue # not a plan line, or have seen one before - match = re.match("(ok|not ok)(?:\s+(\d+)?)?(?:\s+([^#]*[^#\s]+)\s*)?(?:\s+#\s+(TODO|SKIP|skip|todo)(?:\s+(.*))?)?\n", line) + match = re.match(r"(ok|not ok)(?:\s+(\d+)?)?(?:\s+([^#]*[^#\s]+)\s*)?(?:\s+#\s+(TODO|SKIP|skip|todo)(?:\s+(.*))?)?\n", line) if match: # new test, emit current one. _emit_test() @@ -1074,7 +1074,7 @@ def TAP2SubUnit(tap, output_stream): test_name = "test %d%s" % (plan_start, description) plan_start += 1 continue - match = re.match("Bail out\!(?:\s*(.*))?\n", line) + match = re.match(r"Bail out\!(?:\s*(.*))?\n", line) if match: reason, = match.groups() if reason is None: @@ -1086,7 +1086,7 @@ def TAP2SubUnit(tap, output_stream): result = "fail" state = SKIP_STREAM continue - match = re.match("\#.*\n", line) + match = re.match(r"\#.*\n", line) if match: log.append(line[:-1]) continue -- cgit v1.2.1 From cf5ee567bedec28a6951c18098a5c3b96f192837 Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Tue, 15 Jun 2021 12:48:42 -0400 Subject: Revert "Merge pull request #17 from mtreinish/timestamp-output" This reverts commit 1dafb884e47f5fc26232672b01c2a9574577e7be, reversing changes made to 7583ce28db20a0b2ad229a69175949e5a30586fe. This PR had completely broken tests, while I think the feature works it's blocking CI and preventing any merges. I'll rework the PR and resubmit after I get the unittests working. --- python/subunit/_output.py | 29 +------------- python/subunit/tests/test_output_filter.py | 63 ------------------------------ setup.py | 1 - 3 files changed, 1 insertion(+), 92 deletions(-) diff --git a/python/subunit/_output.py b/python/subunit/_output.py index c598c81..aa92646 100644 --- a/python/subunit/_output.py +++ b/python/subunit/_output.py @@ -22,8 +22,6 @@ from optparse import ( ) import sys -from dateutil import parser as date_parser - from subunit import make_stream_binary from subunit.iso8601 import UTC from subunit.v2 import StreamResultToBytes @@ -123,18 +121,6 @@ def parse_arguments(args=None, ParserClass=OptionParser): dest="tags", default=[] ) - parser.add_option( - "--start-time", - help="Specify a time for the test to start", - dest="start_time", - default=None - ) - parser.add_option( - "--stop-time", - help="Specify a time for the test to finish executing", - dest="stop_time", - default=None - ) (options, args) = parser.parse_args(args) if options.mimetype and not options.attach_file: @@ -166,14 +152,6 @@ def set_status_cb(option, opt_str, value, parser, status_name): def generate_stream_results(args, output_writer): - if args.start_time: - start_time = date_parser.parse(args.start_time) - else: - start_time = None - if args.stop_time: - stop_time = date_parser.parse(args.stop_time) - else: - stop_time = None output_writer.startTestRun() if args.attach_file: @@ -192,7 +170,6 @@ def generate_stream_results(args, output_writer): write_status = partial(write_status, mime_type=args.mimetype) if args.tags: write_status = partial(write_status, test_tags=set(args.tags)) - timestamp = start_time or create_timestamp() write_status = partial(write_status, timestamp=create_timestamp()) if args.action not in _FINAL_ACTIONS: write_status = partial(write_status, test_status=args.action) @@ -215,11 +192,7 @@ def generate_stream_results(args, output_writer): if is_last_packet: if args.action in _FINAL_ACTIONS: - if stop_time: - write_status = partial(write_status, test_status=args.action, - timestamp=stop_time) - else: - write_status = partial(write_status, test_status=args.action) + write_status = partial(write_status, test_status=args.action) write_status() diff --git a/python/subunit/tests/test_output_filter.py b/python/subunit/tests/test_output_filter.py index 587fd06..0f61ac5 100644 --- a/python/subunit/tests/test_output_filter.py +++ b/python/subunit/tests/test_output_filter.py @@ -472,69 +472,6 @@ class StatusStreamResultTests(TestCase): ]) ) -class TimeStampTests(TestCase): - scenarios = [ - (s, dict(status=s, option='--' + s)) for s in _FINAL_ACTIONS - ] - - _dummy_timestamp = datetime.datetime(1914, 6, 28, 10, 45, 2, 0, UTC) - - def setUp(self): - super(TimeStampTests, self).setUp() - self.patch(_o, 'create_timestamp', lambda: self._dummy_timestamp) - self.test_id = self.getUniqueString() - - def test_no_timestamps(self): - result = get_result_for([self.option, self.test_id, f.name]) - self.assertThat( - result._events, - MatchesListwise([ - MatchesStatusCall(call='startTestRun'), - MatchesStatusCall(test_id=self.test_id, timestamp=self._dummy_timestamp), - MatchesStatusCall(test_id=self.test_id, timestamp=None), - MatchesStatusCall(call='stopTestRun'), - ])) - - def test_only_start_timestamp(self): - timestamp = datetime.datetime.utcnow() - result = get_result_for([self.option, self.test_id, f.name, - '--start-time', timestamp.isoformat()]) - self.assertThat( - result._events, - MatchesListwise([ - MatchesStatusCall(call='startTestRun'), - MatchesStatusCall(test_id=self.test_id, timestamp=timestamp), - MatchesStatusCall(test_id=self.test_id, timestamp=None), - MatchesStatusCall(call='stopTestRun'), - ])) - - def test_only_stop_timestamp(self): - timestamp = datetime.datetime.utcnow() - result = get_result_for([self.option, self.test_id, f.name, - '--stop-time', timestamp.isoformat()]) - self.assertThat( - result._events, - MatchesListwise([ - MatchesStatusCall(call='startTestRun'), - MatchesStatusCall(test_id=self.test_id, timestamp=self._dummy_timestamp), - MatchesStatusCall(test_id=self.test_id, timestamp=timestamp), - MatchesStatusCall(call='stopTestRun'), - ])) - - def test_start_and_stop_timestamp(self): - timestamp_start = datetime.datetime.utcnow() - timestamp_stop = timestamp_start + datetime.timedelta(minutes=5) - result = get_result_for([self.option, self.test_id, f.name, - '--start-time', timestamp_start.isoformat(), - '--stop-time', timestamp_stop.isoformat()]) - self.assertThat( - result._events, - MatchesListwise([ - MatchesStatusCall(call='startTestRun'), - MatchesStatusCall(test_id=self.test_id, timestamp=timestamp_start), - MatchesStatusCall(test_id=self.test_id, timestamp=timestamp_stop), - MatchesStatusCall(call='stopTestRun'), - ])) class FileDataTests(TestCase): diff --git a/setup.py b/setup.py index e9037e7..8afde6e 100755 --- a/setup.py +++ b/setup.py @@ -12,7 +12,6 @@ else: 'install_requires': [ 'extras', 'testtools>=0.9.34', - 'python-dateutil>=2.4.2', ], 'tests_require': [ 'fixtures', -- cgit v1.2.1 From ea6161ebd86802dd21e92cc79201e03e72f8f95a Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Tue, 15 Jun 2021 13:05:04 -0400 Subject: Pivot CI to github actions With the tight travis quotas for open source projects now it is not a viable provider for running CI on this project anymore. While this project is relatively low activity the quota seems to be preventing jobs from reliably triggering. This commit switches CI to use github actions which doesn't have this limitation. --- .github/workflows/main.yml | 32 ++++++++++++++++++++++++++++++++ .travis.yml | 32 -------------------------------- 2 files changed, 32 insertions(+), 32 deletions(-) create mode 100644 .github/workflows/main.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..bb8cbae --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,32 @@ +name: Tests +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] +jobs: + tests: + name: tests-python${{ matrix.python-version }}-${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + python-version: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9, 'pypy3'] + os: ["ubuntu-latest"] + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install Deps + run: sudo apt-get install check libcppunit-dev + - name: Install package + run: python -m pip install -U '.[test,docs]' + - name: Build + run: autoreconf -fi && ./configure && make + - name: Run make check + run: make check + - name: Run make distcheck + run: make distcheck + - name: Docs build + run: rst2html.py README.rst README.html diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 27593b3..0000000 --- a/.travis.yml +++ /dev/null @@ -1,32 +0,0 @@ -sudo: false -dist: focal -addons: - apt: - packages: - - check - - libcppunit-dev -language: python -python: - - "2.7" - - "3.5" - - "3.6" - - "3.7" - - "3.8" - - "3.9" - - "pypy2.7-7.3.1" - - "pypy3.6-7.3.1" -matrix: - include: - - dist: xenial - python: pypy3.5-7.0.0 -install: - - pip install -U pip - - pip install -U wheel setuptools - - pip install -U .[test,docs] - - pip list - - python --version - - autoreconf -fi && ./configure && make -script: - - make check - - make distcheck - - rst2html.py README.rst README.html -- cgit v1.2.1