Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install .[dev]
sudo apt-get update
sudo apt-get install -y graphviz
- name: Test with pytest
run: pytest

Expand Down Expand Up @@ -59,6 +61,8 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -e .[dev]
sudo apt-get update
sudo apt-get install -y graphviz
- name: Run coverage
run: |
pytest --cov=pgraph --cov-report=xml:coverage.xml
Expand Down
13 changes: 12 additions & 1 deletion tests/test_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,7 @@ def test_plot(self):

def test_dotfile(self):
import pathlib
import unittest.mock

g = UGraph()
v1 = g.add_vertex(coord=[0,0], name='v1')
Expand All @@ -795,7 +796,17 @@ def test_dotfile(self):
g.dotfile(str(path))
self.assertTrue(path.is_file())

g.showgraph()
# showgraph() pops a PDF up in a browser via webbrowser.open() --
# mock that so the test runs headless, but still exercise the real
# dot->PDF rendering and check the result is an actual PDF file.
with unittest.mock.patch('pgraph.PGraph.webbrowser.open') as mock_open:
g.showgraph()

mock_open.assert_called_once()
pdf_url = mock_open.call_args[0][0]
pdf_path = pathlib.Path(pdf_url.removeprefix('file://'))
self.assertTrue(pdf_path.is_file())
self.assertEqual(pdf_path.read_bytes()[:5], b'%PDF-')

class TestDGraph(unittest.TestCase):

Expand Down
Loading