From effbf569ae627950a0812078873932c9ef8a9644 Mon Sep 17 00:00:00 2001 From: Alex Nelson Date: Mon, 12 Apr 2021 12:48:10 -0400 Subject: [PATCH 1/3] Test in Python 3.6 The Python Software Foundation is supporting Python 3.6 until 2021-12-23. CASE should test its tooling in Python 3.6 until that Python release reaches end-of-life. This patch is somewhat an XFAIL - I ran the unit tests in an Ubuntu 18.04 machine and found a feature used in a test is supported in Python >= 3.7. A follow-on patch will correct that issue. Signed-off-by: Alex Nelson --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f97a949..6951885 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.8] + python-version: [ 3.6, 3.8 ] steps: - uses: actions/checkout@v2 From 02e37acab8710529421a5ae64f0405687d9aef81 Mon Sep 17 00:00:00 2001 From: Alex Nelson Date: Mon, 12 Apr 2021 12:50:44 -0400 Subject: [PATCH 2/3] Fix timestamp test in Python 3.6 Signed-off-by: Alex Nelson --- tests/case_file/Makefile | 5 ++++- tests/case_file/sample_txt.py | 5 +++-- tests/requirements.txt | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/case_file/Makefile b/tests/case_file/Makefile index 71961a1..e917f0a 100644 --- a/tests/case_file/Makefile +++ b/tests/case_file/Makefile @@ -96,8 +96,11 @@ kb.ttl: \ mv _$@ $@ sample.txt.done.log: \ + $(tests_srcdir)/.venv.done.log \ sample_txt.py - python3 sample_txt.py sample.txt + source $(tests_srcdir)/venv/bin/activate \ + && python3 sample_txt.py \ + sample.txt touch $@ # Display difference between rdflib default output and compacted output. diff --git a/tests/case_file/sample_txt.py b/tests/case_file/sample_txt.py index ac6722e..625caa9 100644 --- a/tests/case_file/sample_txt.py +++ b/tests/case_file/sample_txt.py @@ -17,13 +17,14 @@ Mtime should be 2010-01-02T03:04:56Z. """ -import datetime import os import sys +import dateutil.parser + with open(sys.argv[1], "w") as out_fh: out_fh.write("test") -target_datetime = datetime.datetime.fromisoformat("2010-01-02T03:04:56+00:00") +target_datetime = dateutil.parser.isoparse("2010-01-02T03:04:56+00:00") target_timestamp = target_datetime.timestamp() os.utime(sys.argv[1], (target_timestamp, target_timestamp)) diff --git a/tests/requirements.txt b/tests/requirements.txt index aed3c61..b31bac3 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,2 +1,3 @@ PyLD pytest +python-dateutil From e59ea529461cfc9a9c1465140b1de9366a5cced7 Mon Sep 17 00:00:00 2001 From: Alex Nelson Date: Mon, 12 Apr 2021 13:31:04 -0400 Subject: [PATCH 3/3] For Github Action CI, pass action's Python 3 in test call The prior patch worked in my local environment, but missed a nuance of Python 3.8 being available in Github's runner, though 3.6 is the action's configured version. The Makefile PYTHON3 variable does a newest-version-first search, so virtualenv wasn't found at runtime. The name of the action's Python 3 command was found via the home page of the setup-python action: https://github.com/marketplace/actions/setup-python Signed-off-by: Alex Nelson --- .github/workflows/ci.yml | 2 +- Makefile | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6951885..63ff0db 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,4 +38,4 @@ jobs: - name: Start from clean state run: make clean - name: Run tests - run: make check + run: make PYTHON3=python check diff --git a/Makefile b/Makefile index a8ed1b9..8d36eba 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,8 @@ SHELL := /bin/bash +PYTHON3 ?= $(shell which python3.9 2>/dev/null || which python3.8 2>/dev/null || which python3.7 2>/dev/null || which python3.6 2>/dev/null || which python3) + all: .PHONY: \ @@ -38,6 +40,7 @@ all: check: \ .git_submodule_init.done.log $(MAKE) \ + PYTHON3=$(PYTHON3) \ --directory tests \ check