From 87457add5d99d189641ed1cec14df5433533ea85 Mon Sep 17 00:00:00 2001 From: Paul Prescod Date: Sat, 20 Nov 2021 04:09:22 -0800 Subject: [PATCH 1/7] Improve test coverage --- tests/test_images.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/test_images.py b/tests/test_images.py index 1fb38fbc..1a574f3e 100644 --- a/tests/test_images.py +++ b/tests/test_images.py @@ -109,6 +109,30 @@ def graphviz_available(): class TestImageOuputStreams: + @mock.patch("subprocess.Popen") + def test_image_outputs_mocked(self, popen): + png = "out.png" + svg = "out.svg" + txt = "out.txt" + dot = "out.dot" + popen.return_value.communicate = lambda: (mock.Mock(), mock.Mock()) + generate_cli.main( + [ + str(sample_yaml), + "--output-file", + png, + "--output-file", + svg, + "--output-file", + txt, + "--output-file", + dot, + ], + standalone_mode=False, + ) + for call in popen.mock_calls: + assert call[1][0][0] == "dot" + def test_image_outputs(self): if not graphviz_available(): pytest.skip("Graphviz is not installed") From 6c6e5dfd656dd6a036d817d47b082aa43fcc379a Mon Sep 17 00:00:00 2001 From: Paul Prescod Date: Fri, 26 Nov 2021 12:04:43 -0800 Subject: [PATCH 2/7] Change workflows to include graphviz sometimes --- .github/workflows/ci.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9a86eb70..234bc5dd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.6", "3.7", "3.8", "3.9"] + python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"] steps: - uses: "actions/checkout@v2" - uses: "actions/setup-python@v1" @@ -105,7 +105,7 @@ jobs: runs-on: windows-latest strategy: matrix: - python-version: ["3.6", "3.9"] + python-version: ["3.6", "3.10"] steps: - uses: "actions/checkout@v2" - uses: "actions/setup-python@v1" @@ -117,6 +117,10 @@ jobs: python -VV python -m pip install --upgrade pip make dev-install + # Snowfakery should work both with and without graphviz. + # On Linux we test without it and on Windows we test with it. + # The Unit tests adapt to both situations + choco install graphviz - name: Run Tests run: python -m pytest From 54af21fff05b12ee74109af536e725c8ffc8966a Mon Sep 17 00:00:00 2001 From: Paul Prescod Date: Fri, 26 Nov 2021 12:11:42 -0800 Subject: [PATCH 3/7] Clean up cross-platform newline issues --- tests/test_images.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_images.py b/tests/test_images.py index 1a574f3e..4649cde6 100644 --- a/tests/test_images.py +++ b/tests/test_images.py @@ -156,7 +156,7 @@ def test_image_outputs(self): ], standalone_mode=False, ) - assert png.read_bytes().startswith(b"\x89PNG\r\n") + assert png.read_bytes().startswith(b"\x89PNG"), png.read_bytes()[0:10] assert svg.read_bytes().startswith(b" Date: Wed, 26 Apr 2023 14:33:21 -0700 Subject: [PATCH 4/7] Update Python versions --- .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 234bc5dd..75f39a89 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"] + python-version: ["3.8", "3.9", "3.11", "3.12"] steps: - uses: "actions/checkout@v2" - uses: "actions/setup-python@v1" From b1fc87a089b5bdad050895923f91ae62e957958f Mon Sep 17 00:00:00 2001 From: Paul Prescod Date: Wed, 26 Apr 2023 14:47:54 -0700 Subject: [PATCH 5/7] Add more versions --- .github/workflows/ci.yml | 2 +- tox.ini | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 40f20137..2c1e41b0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -97,7 +97,7 @@ jobs: runs-on: sfdc-ubuntu-latest strategy: matrix: - python-version: ["3.8", "3.10"] + python-version: ["3.8", "3.12"] steps: - uses: "actions/checkout@v2" - uses: "actions/setup-python@v1" diff --git a/tox.ini b/tox.ini index c3a38b41..99dd0f97 100644 --- a/tox.ini +++ b/tox.ini @@ -16,6 +16,9 @@ install_command = python = 3.8: py38 3.9: py39 + 3.10: py310 + 3.11: py311 + 3.12: py312 [testenv:lint] description = Run all pre-commit hooks. From e7dfc489517208ddeeb10f487de6e2a184337851 Mon Sep 17 00:00:00 2001 From: Paul Prescod Date: Fri, 12 May 2023 09:03:41 -0700 Subject: [PATCH 6/7] Remove reference to Python 3.6 --- .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 2c1e41b0..7b21ad49 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -122,7 +122,7 @@ jobs: runs-on: sfdc-windows-latest strategy: matrix: - python-version: ["3.6", "3.12"] + python-version: ["3.8", "3.12"] steps: - uses: "actions/checkout@v2" - uses: "actions/setup-python@v1" From d96e31b76f4aac40e807d6f0ad337e0d91bea08c Mon Sep 17 00:00:00 2001 From: Paul Prescod Date: Fri, 12 May 2023 09:09:50 -0700 Subject: [PATCH 7/7] Couldn't figure out how to add 3.12 while it's an alpha https://github.com/actions/python-versions/releases --- .github/workflows/ci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7b21ad49..16259201 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,9 +11,9 @@ jobs: test: name: "Python ${{ matrix.python-version }}" runs-on: sfdc-ubuntu-latest - strategy: - matrix: - python-version: ["3.8", "3.9", "3.11", "3.12"] + strategy: # when github action adds 3.12, you can add it here. + matrix: # https://github.com/actions/python-versions/releases + python-version: ["3.8", "3.9", "3.11"] steps: - uses: "actions/checkout@v2" - uses: "actions/setup-python@v1" @@ -97,7 +97,7 @@ jobs: runs-on: sfdc-ubuntu-latest strategy: matrix: - python-version: ["3.8", "3.12"] + python-version: ["3.8", "3.11"] steps: - uses: "actions/checkout@v2" - uses: "actions/setup-python@v1" @@ -122,7 +122,7 @@ jobs: runs-on: sfdc-windows-latest strategy: matrix: - python-version: ["3.8", "3.12"] + python-version: ["3.8", "3.11"] steps: - uses: "actions/checkout@v2" - uses: "actions/setup-python@v1"