diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3b4b761a..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.10"] + 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.10"] + 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.9", "3.10"] + python-version: ["3.8", "3.11"] steps: - uses: "actions/checkout@v2" - uses: "actions/setup-python@v1" @@ -133,7 +133,11 @@ jobs: run: | python -VV python -m pip install --upgrade pip - pip install -r requirements_dev.txt + 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 diff --git a/tests/test_images.py b/tests/test_images.py index 8df0fe30..538005b3 100644 --- a/tests/test_images.py +++ b/tests/test_images.py @@ -130,6 +130,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") @@ -153,7 +177,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"