1+ from __future__ import annotations
2+
13import re
24import subprocess
5+ from pathlib import Path
36
4- import pytest
7+ from pytest import FixtureRequest , fixture
58
69
7- @pytest . fixture (params = [("ra-100000" , 5 , 1000 ), ("annulus" , 100 , 3000 )])
8- def dir_isnap (request , repo_dir ) :
10+ @fixture (params = [("ra-100000" , 5 , 1000 ), ("annulus" , 100 , 3000 )])
11+ def dir_isnap (request : FixtureRequest , repo_dir : Path ) -> tuple [ Path , int , int ] :
912 return (
1013 repo_dir / "Examples" / request .param [0 ],
1114 request .param [1 ],
1215 request .param [2 ],
1316 )
1417
1518
16- @pytest . fixture (
19+ @fixture (
1720 params = [
1821 ("stagpy field" , ["stagpy_T_stream{:05d}.pdf" ]),
1922 ("stagpy field -o=T.v3" , ["stagpy_T_v3{:05d}.pdf" ]),
2023 ("stagpy field -o=T-v3" , ["stagpy_T{:05d}.pdf" , "stagpy_v3{:05d}.pdf" ]),
2124 ]
2225)
23- def all_cmd_field (request , dir_isnap ):
26+ def all_cmd_field (
27+ request : FixtureRequest , dir_isnap : tuple [Path , int , int ]
28+ ) -> tuple [str , list [str ]]:
2429 cmd = request .param [0 ]
2530 cmd += " -p={}" .format (dir_isnap [0 ])
2631 expected_files = []
@@ -29,13 +34,15 @@ def all_cmd_field(request, dir_isnap):
2934 return cmd , expected_files
3035
3136
32- @pytest . fixture (
37+ @fixture (
3338 params = [
3439 ("stagpy rprof" , ["stagpy_rprof_Tmean_{}.pdf" ]),
3540 ("stagpy rprof -o=Tmean,vzabs" , ["stagpy_rprof_Tmean_vzabs_{}.pdf" ]),
3641 ]
3742)
38- def all_cmd_rprof (request , dir_isnap ):
43+ def all_cmd_rprof (
44+ request : FixtureRequest , dir_isnap : tuple [Path , int , int ]
45+ ) -> tuple [str , list [str ]]:
3946 cmd = request .param [0 ]
4047 cmd += " -p={}" .format (dir_isnap [0 ])
4148 expected_files = []
@@ -44,18 +51,20 @@ def all_cmd_rprof(request, dir_isnap):
4451 return cmd , expected_files
4552
4653
47- @pytest . fixture (
54+ @fixture (
4855 params = [
4956 ("stagpy time -o Tmean.Nutop" , ["stagpy_time_Tmean_Nutop.pdf" ]),
5057 ]
5158)
52- def all_cmd_time (request , dir_isnap ):
59+ def all_cmd_time (
60+ request : FixtureRequest , dir_isnap : tuple [str , int , int ]
61+ ) -> tuple [str , list [str ]]:
5362 cmd = request .param [0 ]
5463 cmd += " -p={}" .format (dir_isnap [0 ])
5564 return cmd , request .param [1 ]
5665
5766
58- @pytest . fixture (
67+ @fixture (
5968 params = [
6069 (
6170 "stagpy plates -o v2.dv2 -continents --field T" ,
@@ -67,7 +76,9 @@ def all_cmd_time(request, dir_isnap):
6776 ),
6877 ]
6978)
70- def all_cmd_plates (request , dir_isnap ):
79+ def all_cmd_plates (
80+ request : FixtureRequest , dir_isnap : tuple [str , int , int ]
81+ ) -> tuple [str , list [str ]]:
7182 cmd = request .param [0 ]
7283 cmd += " -p={}" .format (dir_isnap [0 ])
7384 expected_files = []
@@ -76,30 +87,30 @@ def all_cmd_plates(request, dir_isnap):
7687 return cmd , expected_files
7788
7889
79- def helper_test_cli (all_cmd , tmp ) :
90+ def helper_test_cli (all_cmd : tuple [ str , list [ str ]], tmp : Path ) -> None :
8091 subprocess .run (all_cmd [0 ] + " -n={}/stagpy" .format (tmp ), shell = True )
8192 produced_files = sorted (tmp .iterdir ())
8293 expected_files = [tmp / expfile for expfile in sorted (all_cmd [1 ])]
8394 assert produced_files == expected_files
8495
8596
86- def test_field_cli (all_cmd_field , tmp_path ) :
97+ def test_field_cli (all_cmd_field : tuple [ str , list [ str ]], tmp_path : Path ) -> None :
8798 helper_test_cli (all_cmd_field , tmp_path )
8899
89100
90- def test_rprof_cli (all_cmd_rprof , tmp_path ) :
101+ def test_rprof_cli (all_cmd_rprof : tuple [ str , list [ str ]], tmp_path : Path ) -> None :
91102 helper_test_cli (all_cmd_rprof , tmp_path )
92103
93104
94- def test_time_cli (all_cmd_time , tmp_path ) :
105+ def test_time_cli (all_cmd_time : tuple [ str , list [ str ]], tmp_path : Path ) -> None :
95106 helper_test_cli (all_cmd_time , tmp_path )
96107
97108
98- def test_plates_cli (all_cmd_plates , tmp_path ) :
109+ def test_plates_cli (all_cmd_plates : tuple [ str , list [ str ]], tmp_path : Path ) -> None :
99110 helper_test_cli (all_cmd_plates , tmp_path )
100111
101112
102- def test_err_cli ():
113+ def test_err_cli () -> None :
103114 subp = subprocess .run ("stagpy field" , shell = True , stderr = subprocess .PIPE )
104115 reg = re .compile (rb"^Oops!.*\nPlease.*\n\nNoParFileError.*$" )
105116 assert reg .match (subp .stderr )
0 commit comments