Skip to content

Commit e48c4cf

Browse files
committed
test: Make fixture for CliRunner
1 parent 3911108 commit e48c4cf

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

templateflow/tests/test_cli.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
from pathlib import Path
22

33
import click.testing
4+
import pytest
45

56
from .. import cli
67

78

8-
def test_ls_one():
9-
runner = click.testing.CliRunner()
9+
@pytest.fixture
10+
def runner():
11+
return click.testing.CliRunner()
1012

13+
14+
def test_ls_one(runner):
1115
result = runner.invoke(cli.main, ['ls', 'MNI152Lin', '--res', '1', '-s', 'T1w'])
1216

1317
# One result
@@ -21,9 +25,7 @@ def test_ls_one():
2125
assert path.exists()
2226

2327

24-
def test_ls_multi():
25-
runner = click.testing.CliRunner()
26-
28+
def test_ls_multi(runner):
2729
result = runner.invoke(cli.main, ['ls', 'MNI152Lin', '--res', '1', '-s', 'T1w', '-s', 'T2w'])
2830

2931
# Two results
@@ -38,9 +40,7 @@ def test_ls_multi():
3840
assert all(path.exists() for path in paths)
3941

4042

41-
def test_get_one():
42-
runner = click.testing.CliRunner()
43-
43+
def test_get_one(runner):
4444
result = runner.invoke(cli.main, ['get', 'MNI152Lin', '--res', '1', '-s', 'T1w'])
4545

4646
# One result, possible download status before
@@ -54,9 +54,7 @@ def test_get_one():
5454
assert stat_res.st_size == 10669511
5555

5656

57-
def test_get_multi():
58-
runner = click.testing.CliRunner()
59-
57+
def test_get_multi(runner):
6058
result = runner.invoke(cli.main, ['get', 'MNI152Lin', '--res', '1', '-s', 'T1w', '-s', 'T2w'])
6159

6260
# Two result, possible download status before

0 commit comments

Comments
 (0)