Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit bdb4fbd

Browse files
tests: Ignore tests that requires dot if the executable is not present (#519)
1 parent 9954890 commit bdb4fbd

File tree

5 files changed

+21
-0
lines changed

5 files changed

+21
-0
lines changed

‎README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ You can now create an instance:
9999
This state machine can be represented graphically as follows:
100100

101101
```py
102+
>>> # This example will only run on automated tests if dot is present
103+
>>> getfixture("requires_dot_installed")
102104
>>> img_path = "docs/images/readme_trafficlightmachine.png"
103105
>>> sm._graph().write_png(img_path)
104106

‎conftest.py‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import shutil
12
import sys
23

34
import pytest
@@ -31,3 +32,14 @@ def pytest_ignore_collect(collection_path, path, config):
3132

3233
if "django_project" in str(path):
3334
return True
35+
36+
37+
@pytest.fixture(scope="session")
38+
def has_dot_installed():
39+
return bool(shutil.which("dot"))
40+
41+
42+
@pytest.fixture()
43+
def requires_dot_installed(request, has_dot_installed):
44+
if not has_dot_installed:
45+
pytest.skip(f"Test {request.node.nodeid} requires 'dot' that is not installed.")

‎docs/diagram.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ If you find the resolution of the image lacking, you can
7474
The current {ref}`state` is also highlighted:
7575

7676
``` py
77+
>>> # This example will only run on automated tests if dot is present
78+
>>> getfixture("requires_dot_installed")
7779

7880
>>> from statemachine.contrib.diagram import DotGraphMachine
7981

‎docs/transitions.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ Example:
131131
Usage:
132132

133133
```py
134+
>>> # This example will only run on automated tests if dot is present
135+
>>> getfixture("requires_dot_installed")
136+
134137
>>> sm = TestStateMachine()
135138

136139
>>> sm._graph().write_png("docs/images/test_state_machine_internal.png")

‎tests/test_contrib_diagram.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
from statemachine.contrib.diagram import main
88
from statemachine.contrib.diagram import quickchart_write_svg
99

10+
pytestmark = pytest.mark.usefixtures("requires_dot_installed")
11+
1012

1113
@pytest.fixture(
1214
params=[

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /