File tree Expand file tree Collapse file tree 1 file changed +18
-9
lines changed Expand file tree Collapse file tree 1 file changed +18
-9
lines changed Original file line number Diff line number Diff line change
1
+ import logging
2
+ import os
1
3
import pytest
2
4
import tempfile
3
- import os
4
- import logging
5
+ import urllib .request
6
+ from urllib .parse import urlparse
7
+ from uuid import uuid4
8
+
5
9
6
10
from lib .commands import SSHCommandFailed
7
11
from .helpers import load_results_from_csv
@@ -92,13 +96,18 @@ def pytest_addoption(parser):
92
96
"--prev-csv" ,
93
97
action = "store" ,
94
98
default = None ,
95
- help = "Path to previous CSV results file for comparison" ,
99
+ help = "Path/URI to previous CSV results file for comparison" ,
96
100
)
97
101
98
102
@pytest .fixture (scope = "session" )
99
- def prev_results (request ):
100
- csv_path = request .config .getoption ("--prev-csv" )
101
- results = {}
102
- if csv_path and os .path .exists (csv_path ):
103
- load_results_from_csv (csv_path )
104
- return results
103
+ def prev_results (pytestconfig ):
104
+ csv_uri = pytestconfig .getoption ("--prev-csv" )
105
+ if not csv_uri :
106
+ return {}
107
+ csv_path = csv_uri
108
+ if urlparse (csv_uri ).scheme != "" :
109
+ csv_path = f"{ uuid4 ()} .csv"
110
+ urllib .request .urlretrieve (csv_uri , csv_path )
111
+ if not os .path .exists (csv_path ):
112
+ raise FileNotFoundError (csv_path )
113
+ return load_results_from_csv (csv_path )
You can’t perform that action at this time.
0 commit comments