8000 MNT Change mark and fixture names for adding files (#1365) · sphinx-gallery/sphinx-gallery@e7eb5ec · GitHub
[go: up one dir, main page]

Skip to content

Commit e7eb5ec

Browse files
MNT Change mark and fixture names for adding files (#1365)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent daeb602 commit e7eb5ec

File tree

4 files changed

+43
-45
lines changed

4 files changed

+43
-45
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,6 @@ filterwarnings = [
166166
]
167167
junit_family = "xunit2"
168168
markers = [
169-
"conf_file: Configuration file.",
169+
"add_conf: Configuration file.",
170170
"add_rst: Add rst file to src.",
171171
]

sphinx_gallery/tests/conftest.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ def req_pil():
137137
@pytest.fixture
138138
def conf_file(request):
139139
try:
140-
env = request.node.get_closest_marker("conf_file")
140+
env = request.node.get_closest_marker("add_conf")
141141
except AttributeError: # old pytest
142-
env = request.node.get_marker("conf_file")
142+
env = request.node.get_marker("add_conf")
143143
kwargs = env.kwargs if env else {}
144144
result = {
145145
"content": "",
@@ -151,7 +151,7 @@ def conf_file(request):
151151

152152

153153
@pytest.fixture
154-
def add_rst(request):
154+
def rst_file(request):
155155
try:
156156
env = request.node.get_closest_marker("add_rst")
157157
except AttributeError: # old pytest
@@ -208,18 +208,18 @@ def build_sphinx_app(self, *args, **kwargs):
208208

209209

210210
@pytest.fixture
211-
def sphinx_app_wrapper(tmpdir, conf_file, add_rst, req_mpl, req_pil):
211+
def sphinx_app_wrapper(tmpdir, conf_file, rst_file, req_mpl, req_pil):
212212
_fixturedir = Path(__file__).parent / "testconfs"
213213
srcdir = Path(tmpdir) / "config_test"
214214
shutil.copytree(_fixturedir, srcdir)
215215
# Copy files to 'examples/' as well because default `examples_dirs` is
216216
# '../examples' - for tests where we don't update config
217217
shutil.copytree((_fixturedir / "src"), (Path(tmpdir) / "examples"))
218-
if add_rst:
218+
if rst_file:
219219
with open((srcdir / "minigallery_test.rst"), "w") as rstfile:
220-
rstfile.write(add_rst)
220+
rstfile.write(rst_file)
221221
# Add nested gallery
222-
if "sub_folder/sub_sub_folder" in add_rst:
222+
if "sub_folder/sub_sub_folder" in rst_file:
223223
dir_path = srcdir / "src" / "sub_folder" / "sub_sub_folder"
224224
dir_path.mkdir(parents=True)
225225
with open((dir_path / "plot_nested.py"), "w") as pyfile:

sphinx_gallery/tests/test_gen_gallery.py

Lines changed: 34 additions & 36 deletions
< 10000 tr class="diff-line-row">
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def test_serializable(sphinx_app_wrapper):
8080
assert not bad, f"Non-serializable values found:\n{bad}"
8181

8282

83-
@pytest.mark.conf_file(
83+
@pytest.mark.add_conf(
8484
content="""
8585
sphinx_gallery_conf = {
8686
'examples_dirs': 'src',
@@ -100,7 +100,7 @@ def test_no_warning_simple_config(sphinx_app_wrapper):
100100
assert build_warn == ""
101101

102102

103-
@pytest.mark.conf_file(
103+
@pytest.mark.add_conf(
104104
content="""
105105
sphinx_gallery_conf = {
106106
'examples_dirs': ['src', 'excess'],
@@ -123,15 +123,15 @@ def test_unequal_examples_gallery_dirs(sphinx_app_wrapper):
123123
ConfigError,
124124
"Unknown string option for reset_modules",
125125
id="Resetter unknown",
126-
marks=pytest.mark.conf_file(
126+
marks=pytest.mark.add_conf(
127127
content="sphinx_gallery_conf={'reset_modules': ('f',)}"
128128
),
129129
),
130130
pytest.param(
131131
ConfigError,
132132
"reset_modules.* must be callable",
133133
id="Resetter not callable",
134-
marks=pytest.mark.conf_file(
134+
marks=pytest.mark.add_conf(
135135
content="sphinx_gallery_conf={'reset_modules': (1.,),}"
136136
),
137137
),
@@ -149,15 +149,15 @@ def test_bad_reset(sphinx_app_wrapper, err_class, err_match):
149149
ConfigError,
150150
"'reset_modules_order' config allowed types",
151151
id="Resetter unknown",
152-
marks=pytest.mark.conf_file(
152+
marks=pytest.mark.add_conf(
153153
content=("sphinx_gallery_conf=" "{'reset_modules_order': 1,}")
154154
),
155155
),
156156
pytest.param(
157157
ConfigError,
158158
"reset_modules_order must be in",
159159
id="reset_modules_order not valid",
160-
marks=pytest.mark.conf_file(
160+
marks=pytest.mark.add_conf(
161161
content=("sphinx_gallery_conf=" "{'reset_modules_order': 'invalid',}")
162162
),
163163
),
@@ -175,15 +175,13 @@ def test_bad_reset_modules_order(sphinx_app_wrapper, err_class, err_match):
175175
ConfigError,
176176
"Unknown css",
177177
id="CSS str error",
178-
marks=pytest.mark.conf_file(
179-
content="sphinx_gallery_conf={'css': ('foo',)}"
180-
),
178+
marks=pytest.mark.add_conf(content="sphinx_gallery_conf={'css': ('foo',)}"),
181179
),
182180
pytest.param(
183181
ConfigError,
184182
"config allowed types:",
185183
id="CSS type error",
186-
marks=pytest.mark.conf_file(content="sphinx_gallery_conf={'css': 1.}"),
184+
marks=pytest.mark.add_conf(content="sphinx_gallery_conf={'css': 1.}"),
187185
),
188186
],
189187
)
@@ -203,7 +201,7 @@ def test_bad_api():
203201
_fill_gallery_conf_defaults(sphinx_gallery_conf)
204202

205203

206-
@pytest.mark.conf_file(
204+
@pytest.mark.add_conf(
207205
content="""
208206
sphinx_gallery_conf = {
209207
'backreferences_dir': os.path.join('gen_modules', 'backreferences'),
@@ -284,7 +282,7 @@ def _check_order(sphinx_app, key):
284282
assert order == [1, 2, 3]
285283

286284

287-
@pytest.mark.conf_file(
285+
@pytest.mark.add_conf(
288286
content="""
289287
sphinx_gallery_conf = {
290288
'examples_dirs': 'src',
@@ -297,7 +295,7 @@ def test_example_sorting_default(sphinx_app_wrapper):
297295
_check_order(sphinx_app, "lines")
298296

299297

300-
@pytest.mark.conf_file(
298+
@pytest.mark.add_conf(
301299
content="""
302300
sphinx_gallery_conf = {
303301
'examples_dirs': 'src',
@@ -311,7 +309,7 @@ def test_example_sorting_filesize(sphinx_app_wrapper):
311309
_check_order(sphinx_app, "filesize")
312310

313311

314-
@pytest.mark.conf_file(
312+
@pytest.mark.add_conf(
315313
content="""
316314
sphinx_gallery_conf = {
317315
'examples_dirs': 'src',
@@ -325,7 +323,7 @@ def test_example_sorting_filename(sphinx_app_wrapper):
325323
_check_order(sphinx_app, "filename")
326324

327325

328-
@pytest.mark.conf_file(
326+
@pytest.mark.add_conf(
329327
content="""
330328
sphinx_gallery_conf = {
331329
'examples_dirs': 'src',
@@ -407,7 +405,7 @@ def test_collect_gallery_files_ignore_pattern(tmpdir, gallery_conf):
407405
assert collected_files == expected_files
408406

409407

410-
@pytest.mark.conf_file(
408+
@pytest.mark.add_conf(
411409
content="""
412410
sphinx_gallery_conf = {
413411
'backreferences_dir' : os.path.join('modules', 'gen'),
@@ -439,7 +437,7 @@ def test_binder_copy_files(sphinx_app_wrapper):
439437
).exists()
440438

441439

442-
@pytest.mark.conf_file(
440+
@pytest.mark.add_conf(
443441
content="""
444442
sphinx_gallery_conf = {
445443
'examples_dirs': 'src',
@@ -474,7 +472,7 @@ def test_failing_examples_raise_exception(sphinx_app_wrapper):
474472
assert bad_line in tb
475473

476474

477-
@pytest.mark.conf_file(
475+
@pytest.mark.add_conf(
478476
content="""
479477
sphinx_gallery_conf = {
480478
'examples_dirs': 'src',
@@ -490,7 +488,7 @@ def test_expected_failing_examples_were_executed(sphinx_app_wrapper):
490488
sphinx_app_wrapper.build_sphinx_app()
491489

492490

493-
@pytest.mark.conf_file(
491+
@pytest.mark.add_conf(
494492
content="""
495493
sphinx_gallery_conf = {
496494
'examples_dirs': 'src',
@@ -510,7 +508,7 @@ def test_only_warn_on_example_error(sphinx_app_wrapper):
510508
assert "WARNING: Here is a summary of the problems" in build_warn
511509

512510

513-
@pytest.mark.conf_file(
511+
@pytest.mark.add_conf(
514512
content="""
515513
sphinx_gallery_conf = {
516514
'examples_dirs': 'src',
@@ -530,7 +528,7 @@ def test_only_warn_on_example_error_sphinx_warning(sphinx_app_wrapper):
530528
assert "plot_3.py unexpectedly failed to execute" in exc
531529

532530

533-
@pytest.mark.conf_file(
531+
@pytest.mark.add_conf(
534532
content="""
535533
sphinx_gallery_conf = {
536534
'examples_dirs': 'src',
@@ -545,7 +543,7 @@ def test_examples_not_expected_to_pass(sphinx_app_wrapper):
545543
assert "expected to fail, but not failing" in exc
546544

547545

548-
@pytest.mark.conf_file(
546+
@pytest.mark.add_conf(
549547
content="""
550548
from sphinx_gallery.gen_rst import _sg_call_memory_noop
551549
@@ -566,13 +564,13 @@ def test_show_memory_callable(sphinx_app_wrapper):
566564
[
567565
pytest.param(
568566
id="first notebook cell",
569-
marks=pytest.mark.conf_file(
567+
marks=pytest.mark.add_conf(
570568
content="""sphinx_gallery_conf = {'first_notebook_cell': 2,}"""
571569
),
572570
),
573571
pytest.param(
574572
id="last notebook cell",
575-
marks=pytest.mark.conf_file(
573+
marks=pytest.mark.add_conf(
576574
content="""sphinx_gallery_conf = {'last_notebook_cell': 2,}"""
577575
),
578576
),
@@ -585,7 +583,7 @@ def test_notebook_cell_config(sphinx_app_wrapper):
585583
fill_gallery_conf_defaults(app, app.config, check_keys=False)
586584

587585

588-
@pytest.mark.conf_file(
586+
@pytest.mark.add_conf(
589587
content="""
590588
sphinx_gallery_conf = {
591589
'backreferences_dir': False,
@@ -598,7 +596,7 @@ def test_backreferences_dir_config(sphinx_app_wrapper):
598596
fill_gallery_conf_defaults(app, app.config, check_keys=False)
599597

600598

601-
@pytest.mark.conf_file(
599+
@pytest.mark.add_conf(
602600
content="""
603601
sphinx_gallery_conf = {
604602
'examples_dirs': 'src',
@@ -612,7 +610,7 @@ def test_minigallery_no_backreferences_dir(sphinx_app_wrapper):
612610
assert "'backreferences_dir' config is None, minigallery" in build_warn
613611

614612

615-
@pytest.mark.conf_file(
613+
@pytest.mark.add_conf(
616614
content="""
617615
import pathlib
618616
@@ -626,7 +624,7 @@ def test_backreferences_dir_pathlib_config(sphinx_app_wrapper):
626624
fill_gallery_conf_defaults(app, app.config, check_keys=False)
627625

628626

629-
@pytest.mark.conf_file(
627+
@pytest.mark.add_conf(
630628
content="""
631629
sphinx_gallery_conf = {
632630
'examples_dirs': 'src',
@@ -648,7 +646,7 @@ def test_minigallery_not_in_examples_dirs(sphinx_app_wrapper):
648646
sphinx_app_wrapper.build_sphinx_app()
649647

650648

651-
@pytest.mark.conf_file(
649+
@pytest.mark.add_conf(
652650
content="""
653651
sphinx_gallery_conf = {
654652
'examples_dirs': ['src', 'src/sub_folder/sub_sub_folder'],
@@ -688,7 +686,7 @@ def test_write_api_usage_noop(sphinx_app_wrapper):
688686
write_api_entry_usage(sphinx_app_wrapper.create_sphinx_app(), list(), None)
689687

690688

691-
@pytest.mark.conf_file(
689+
@pytest.mark.add_conf(
692690
content="""
693691
sphinx_gallery_conf = {
694692
'pypandoc': ['list',],
@@ -704,7 +702,7 @@ def test_pypandoc_config_list(sphinx_app_wrapper):
704702
fill_gallery_conf_defaults(app, app.config, check_keys=False)
705703

706704

707-
@pytest.mark.conf_file(
705+
@pytest.mark.add_conf(
708706
content="""
709707
sphinx_gallery_conf = {
710708
'pypandoc': {'bad key': 1},
@@ -719,7 +717,7 @@ def test_pypandoc_config_keys(sphinx_app_wrapper):
719717
fill_gallery_conf_defaults(app, app.config, check_keys=False)
720718

721719

722-
@pytest.mark.conf_file(
720+
@pytest.mark.add_conf(
723721
content="""
724722
extensions += ['jupyterlite_sphinx']
725723
@@ -746,7 +744,7 @@ def test_create_jupyterlite_contents(sphinx_app_wrapper):
746744
).exists()
747745

748746

749-
@pytest.mark.conf_file(
747+
@pytest.mark.add_conf(
750748
content="""
751749
extensions += ['jupyterlite_sphinx']
752750
@@ -774,7 +772,7 @@ def test_create_jupyterlite_contents_non_default_contents(sphinx_app_wrapper):
774772
).exists()
775773

776774

777-
@pytest.mark.conf_file(
775+
@pytest.mark.add_conf(
778776
content="""
779777
sphinx_gallery_conf = {
780778
'backreferences_dir' : os.path.join('modules', 'gen'),
@@ -793,7 +791,7 @@ def test_create_jupyterlite_contents_without_jupyterlite_sphinx_loaded(
793791
assert not Path(sphinx_app.srcdir, "jupyterlite_contents").exists()
794792

795793

796-
@pytest.mark.conf_file(
794+
@pytest.mark.add_conf(
797795
content="""
798796
extensions += ['jupyterlite_sphinx']
799797
@@ -818,7 +816,7 @@ def test_create_jupyterlite_contents_with_jupyterlite_disabled_via_config(
818816
assert not Path(sphinx_app.outdir, "jupyterlite_contents").exists()
819817

820818

821-
@pytest.mark.conf_file(
819+
@pytest.mark.add_conf(
822820
content="""
823821
extensions += ['jupyterlite_sphinx']
824822

sphinx_gallery/tests/test_load_style.py

< 70E3 div class="d-flex flex-items-center gap-1 pl-1">Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import pytest
66

77

8-
@pytest.mark.conf_file(extensions=["sphinx_gallery.load_style"])
8+
@pytest.mark.add_conf(extensions=["sphinx_gallery.load_style"])
99
def test_load_style(sphinx_app_wrapper):
1010
"""Testing that style loads properly."""
1111
sphinx_app = sphinx_app_wrapper.build_sphinx_app()

0 commit comments

Comments
 (0)
0