Skip to content

Commit 671d7ed

Browse files
committed
Format docstring code snippets
1 parent bc7a47c commit 671d7ed

4 files changed

Lines changed: 31 additions & 23 deletions

File tree

coincidence/fixtures.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def tmp_pathplus(tmp_path: Path) -> PathPlus:
6969
7070
pytest_plugins = ("coincidence", )
7171
72+
7273
def test_something(tmp_pathplus: PathPlus):
7374
assert True
7475
""" # noqa: D400
@@ -96,6 +97,7 @@ def fixed_datetime(monkeypatch) -> Iterator:
9697
.. code-block:: python
9798
9899
import datetime
100+
99101
print(datetime.datetime.now())
100102
101103
Using ``from datetime import datetime`` won't work.

coincidence/params.py

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -152,15 +152,18 @@ def param(
152152
153153
**Examples:**
154154
155-
.. code-block:: python
155+
.. code-block:: python3
156156
157-
@pytest.mark.parametrize("test_input, expected", [
158-
("3+5", 8),
159-
param("6*9", 42, marks=pytest.mark.xfail),
160-
param("2**2", 4, idx=0),
161-
param("3**2", 9, id="3^2"),
162-
param("sqrt(9)", 3, key=itemgetter(0)),
163-
])
157+
@pytest.mark.parametrize(
158+
"test_input, expected",
159+
[
160+
("3+5", 8),
161+
param("6*9", 42, marks=pytest.mark.xfail),
162+
param("2**2", 4, idx=0),
163+
param("3**2", 9, id="3^2"),
164+
param("sqrt(9)", 3, key=itemgetter(0)),
165+
],
166+
)
164167
def test_eval(test_input, expected):
165168
assert eval (test_input) == expected
166169
@@ -201,31 +204,32 @@ def parametrized_versions(
201204
.. code-block:: python
202205
203206
@pytest.mark.parametrize(
204-
"version",
205-
parametrized_versions(
206-
3.6,
207-
3.7,
208-
3.8,
209-
reason="Output differs on each version.",
210-
),
211-
)
207+
"version",
208+
parametrized_versions(
209+
3.6,
210+
3.7,
211+
3.8,
212+
reason="Output differs on each version.",
213+
),
214+
)
212215
def test_something(version: str):
213216
pass
214217
215218
216219
.. code-block:: python
217220
218221
@pytest.fixture(
219-
params=parametrized_versions(
220-
3.6,
221-
3.7,
222-
3.8,
223-
reason="Output differs on each version.",
224-
),
225-
)
222+
params=parametrized_versions(
223+
3.6,
224+
3.7,
225+
3.8,
226+
reason="Output differs on each version.",
227+
),
228+
)
226229
def version(request):
227230
return request.param
228231
232+
229233
def test_something(version: str):
230234
pass
231235

coincidence/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ def with_fixed_datetime(fixed_datetime: datetime.datetime) -> Iterator:
107107
.. code-block:: python
108108
109109
import datetime
110+
110111
print(datetime.datetime.now())
111112
112113
Using ``from datetime import datetime`` won't work.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ directives = [ "code-block",]
141141

142142
[tool.snippet-fmt.languages.python]
143143
reformat = true
144+
sort_imports = false
144145

145146
[tool.snippet-fmt.languages.TOML]
146147
reformat = true

0 commit comments

Comments
 (0)