Skip to content

Commit e37f3ac

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 4192b75 commit e37f3ac

2 files changed

Lines changed: 35 additions & 72 deletions

File tree

tests/test_cli.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -362,15 +362,12 @@ def test_get_plugin_info_str():
362362
{"mdformat-tables": ("0.1.0", ["tables"])},
363363
{"mdformat-black": ("12.1.0", ["python"])},
364364
)
365-
assert (
366-
info
367-
== """\
365+
assert info == """\
368366
installed codeformatters:
369367
mdformat-black: python
370368
371369
installed extensions:
372370
mdformat-tables: tables"""
373-
)
374371

375372

376373
def test_no_timestamp_modify(tmp_path):

tests/test_plugins.py

Lines changed: 34 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,18 @@ def fmt_func(code, info):
3131

3232
monkeypatch.setitem(CODEFORMATTERS, "lang", fmt_func)
3333
text = mdformat.text(
34-
dedent(
35-
"""\
34+
dedent("""\
3635
```lang
3736
a
3837
```
39-
"""
40-
),
38+
"""),
4139
codeformatters={"lang"},
4240
)
43-
assert text == dedent(
44-
"""\
41+
assert text == dedent("""\
4542
```lang
4643
dummy
4744
```
48-
"""
49-
)
45+
""")
5046

5147

5248
def test_code_formatter__empty_str(monkeypatch):
@@ -55,22 +51,18 @@ def fmt_func(code, info):
5551

5652
monkeypatch.setitem(CODEFORMATTERS, "lang", fmt_func)
5753
text = mdformat.text(
58-
dedent(
59-
"""\
54+
dedent("""\
6055
~~~lang
6156
aag
6257
gw
6358
~~~
64-
"""
65-
),
59+
"""),
6660
codeformatters={"lang"},
6761
)
68-
assert text == dedent(
69-
"""\
62+
assert text == dedent("""\
7063
```lang
7164
```
72-
"""
73-
)
65+
""")
7466

7567

7668
def test_code_formatter__no_end_newline(monkeypatch):
@@ -79,22 +71,18 @@ def fmt_func(code, info):
7971

8072
monkeypatch.setitem(CODEFORMATTERS, "lang", fmt_func)
8173
text = mdformat.text(
82-
dedent(
83-
"""\
74+
dedent("""\
8475
```lang
8576
```
86-
"""
87-
),
77+
"""),
8878
codeformatters={"lang"},
8979
)
90-
assert text == dedent(
91-
"""\
80+
assert text == dedent("""\
9281
```lang
9382
dummy
9483
dum
9584
```
96-
"""
97-
)
85+
""")
9886

9987

10088
def test_code_formatter__interface(monkeypatch):
@@ -103,73 +91,61 @@ def fmt_func(code, info):
10391

10492
monkeypatch.setitem(CODEFORMATTERS, "lang", fmt_func)
10593
text = mdformat.text(
106-
dedent(
107-
"""\
94+
dedent("""\
10895
``` lang long
10996
multi
11097
mul
11198
```
112-
"""
113-
),
99+
"""),
114100
codeformatters={"lang"},
115101
)
116-
assert text == dedent(
117-
"""\
102+
assert text == dedent("""\
118103
```lang long
119104
lang longmulti
120105
mul
121106
multi
122107
mul
123108
```
124-
"""
125-
)
109+
""")
126110

127111

128112
def test_single_token_extension(monkeypatch):
129113
"""Test the front matter plugin, as a single token extension example."""
130114
plugin_name = "text_editor"
131115
monkeypatch.setitem(PARSER_EXTENSIONS, plugin_name, TextEditorPlugin)
132116
text = mdformat.text(
133-
dedent(
134-
"""\
117+
dedent("""\
135118
# Example Heading
136119
137120
Example paragraph.
138-
"""
139-
),
121+
"""),
140122
extensions=[plugin_name],
141123
)
142-
assert text == dedent(
143-
"""\
124+
assert text == dedent("""\
144125
# All text is like this now!
145126
146127
All text is like this now!
147-
"""
148-
)
128+
""")
149129

150130

151131
def test_table(monkeypatch):
152132
"""Test the table plugin, as a multi-token extension example."""
153133
monkeypatch.setitem(PARSER_EXTENSIONS, "table", TablePlugin)
154134
text = mdformat.text(
155-
dedent(
156-
"""\
135+
dedent("""\
157136
|a|b|
158137
|-|-|
159138
|c|d|
160139
161140
other text
162-
"""
163-
),
141+
"""),
164142
extensions=["table", "table"],
165143
)
166-
assert text == dedent(
167-
"""\
144+
assert text == dedent("""\
168145
dummy 21
169146
170147
other text
171-
"""
172-
)
148+
""")
173149

174150

175151
class ExamplePluginWithGroupedCli:
@@ -198,14 +174,12 @@ def test_cli_options_group(monkeypatch, tmp_path):
198174
file_path = tmp_path / "test_markdown.md"
199175
conf_path = tmp_path / ".mdformat.toml"
200176
file_path.touch()
201-
conf_path.write_text(
202-
"""\
177+
conf_path.write_text("""\
203178
[plugin.table]
204179
override_toml = 'failed'
205180
toml_only = true
206181
dont_override_toml = 'dont override this with None if CLI opt not given'
207-
"""
208-
)
182+
""")
209183

210184
with patch.object(MDRenderer, "render", return_value="") as mock_render:
211185
assert (
@@ -365,22 +339,18 @@ def test_postprocess_plugins(monkeypatch):
365339
monkeypatch.setitem(PARSER_EXTENSIONS, suffix_plugin_name, SuffixPostprocessPlugin)
366340
monkeypatch.setitem(PARSER_EXTENSIONS, prefix_plugin_name, PrefixPostprocessPlugin)
367341
text = mdformat.text(
368-
dedent(
369-
"""\
342+
dedent("""\
370343
# Example Heading.
371344
372345
Example paragraph.
373-
"""
374-
),
346+
"""),
375347
extensions=[suffix_plugin_name, prefix_plugin_name],
376348
)
377-
assert text == dedent(
378-
"""\
349+
assert text == dedent("""\
379350
# Prefixed!Example Heading.Suffixed!
380351
381352
Prefixed!Example paragraph.Suffixed!
382-
"""
383-
)
353+
""")
384354

385355

386356
def test_load_entrypoints(tmp_path, monkeypatch):
@@ -392,20 +362,16 @@ def test_load_entrypoints(tmp_path, monkeypatch):
392362
metadata_path = dist_info_path / "METADATA"
393363
# The modules here will get loaded so use ones we know will always exist
394364
# (even though they aren't actual extensions).
395-
entry_points_path.write_text(
396-
"""\
365+
entry_points_path.write_text("""\
397366
[mdformat.parser_extension]
398367
ext1=mdformat.plugins
399368
ext2=mdformat.plugins
400-
"""
401-
)
402-
metadata_path.write_text(
403-
"""\
369+
""")
370+
metadata_path.write_text("""\
404371
Metadata-Version: 2.1
405372
Name: mdformat-gfm
406373
Version: 0.3.6
407-
"""
408-
)
374+
""")
409375
distro = importlib.metadata.PathDistribution(dist_info_path)
410376
entrypoints = distro.entry_points
411377

0 commit comments

Comments
 (0)