Skip to content

Commit 1b8aaed

Browse files
Jorge Fernandez HernandezJorge Fernandez Hernandez
authored andcommitted
GAIAMNGT-1700 Make use of Path instead of os.path
1 parent 75b7124 commit 1b8aaed

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

astroquery/gaia/tests/test_gaiatap.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@ def test_datalink_querier_load_data_vot_exception(mock_datalink_querier, overwri
808808
now = datetime.datetime.now(datetime.timezone.utc)
809809
output_file = 'datalink_output_' + now.strftime("%Y%m%dT%H%M%S") + '.zip'
810810

811-
file_final = Path(os.getcwd() + '/' + output_file)
811+
file_final = Path(os.getcwd(), output_file)
812812

813813
Path(file_final).touch()
814814

@@ -858,7 +858,7 @@ def test_datalink_querier_load_data_vot(mock_datalink_querier):
858858
files = os.listdir(direc)
859859
# Filtering only the files.
860860
files = [f for f in files if
861-
os.path.isfile(direc + '/' + f) and f.endswith(".zip") and f.startswith('datalink_output')]
861+
Path(direc, f).is_file() and f.endswith(".zip") and f.startswith('datalink_output')]
862862

863863
assert len(files) == 1
864864
datalink_output = files[0]
@@ -896,7 +896,7 @@ def test_datalink_querier_load_data_ecsv(mock_datalink_querier_ecsv):
896896
files = os.listdir(direc)
897897
# Filtering only the files.
898898
files = [f for f in files if
899-
os.path.isfile(direc + '/' + f) and f.endswith(".zip") and f.startswith('datalink_output')]
899+
Path(direc, f).is_file() and f.endswith(".zip") and f.startswith('datalink_output')]
900900

901901
assert len(files) == 1
902902
datalink_output = files[0]
@@ -934,7 +934,7 @@ def test_datalink_querier_load_data_csv(mock_datalink_querier_csv):
934934
files = os.listdir(direc)
935935
# Filtering only the files.
936936
files = [f for f in files if
937-
os.path.isfile(direc + '/' + f) and f.endswith(".zip") and f.startswith('datalink_output')]
937+
Path(direc, f).is_file() and f.endswith(".zip") and f.startswith('datalink_output')]
938938

939939
assert len(files) == 1
940940
datalink_output = files[0]
@@ -973,7 +973,7 @@ def test_datalink_querier_load_data_fits(mock_datalink_querier_fits):
973973
files = os.listdir(direc)
974974
# Filtering only the files.
975975
files = [f for f in files if
976-
os.path.isfile(direc + '/' + f) and f.endswith(".zip") and f.startswith('datalink_output')]
976+
Path(direc, f).is_file() and f.endswith(".zip") and f.startswith('datalink_output')]
977977

978978
assert len(files) == 1
979979
datalink_output = files[0]
@@ -1002,7 +1002,7 @@ def test_load_data_vot(monkeypatch, tmp_path, tmp_path_factory):
10021002
now = datetime.datetime.now(datetime.timezone.utc)
10031003
output_file = 'datalink_output_' + now.strftime("%Y%m%dT%H%M%S") + '.zip'
10041004

1005-
path = Path(os.getcwd() + '/' + output_file)
1005+
path = Path(os.getcwd(), output_file)
10061006

10071007
with open(DL_PRODUCTS_VOT, 'rb') as file:
10081008
zip_bytes = file.read()
@@ -1039,7 +1039,7 @@ def test_load_data_fits(monkeypatch, tmp_path, tmp_path_factory):
10391039
now = datetime.datetime.now(datetime.timezone.utc)
10401040
output_file = 'datalink_output_' + now.strftime("%Y%m%dT%H%M%S") + '.zip'
10411041

1042-
path = Path(os.getcwd() + '/' + output_file)
1042+
path = Path(os.getcwd(), output_file)
10431043

10441044
with open(DL_PRODUCTS_FITS, 'rb') as file:
10451045
zip_bytes = file.read()
@@ -1054,7 +1054,7 @@ def load_data_monkeypatched(self, params_dict, output_file, verbose):
10541054
"RETRIEVAL_TYPE": "epoch_photometry",
10551055
"DATA_STRUCTURE": "INDIVIDUAL",
10561056
"USE_ZIP_ALWAYS": "true"}
1057-
assert output_file == os.getcwd() + '/' + 'datalink_output.zip'
1057+
assert output_file == Path(os.getcwd(), 'datalink_output.zip')
10581058
assert verbose is True
10591059

10601060
monkeypatch.setattr(TapPlus, "load_data", load_data_monkeypatched)
@@ -1075,7 +1075,7 @@ def test_load_data_csv(monkeypatch, tmp_path, tmp_path_factory):
10751075
now = datetime.datetime.now(datetime.timezone.utc)
10761076
output_file = 'datalink_output_' + now.strftime("%Y%m%dT%H%M%S") + '.zip'
10771077

1078-
path = Path(os.getcwd() + '/' + output_file)
1078+
path = Path(os.getcwd(), output_file)
10791079

10801080
with open(DL_PRODUCTS_CSV, 'rb') as file:
10811081
zip_bytes = file.read()
@@ -1111,7 +1111,7 @@ def test_load_data_ecsv(monkeypatch, tmp_path, tmp_path_factory):
11111111
now = datetime.datetime.now(datetime.timezone.utc)
11121112
output_file = 'datalink_output_' + now.strftime("%Y%m%dT%H%M%S") + '.zip'
11131113

1114-
path = Path(os.getcwd() + '/' + output_file)
1114+
path = Path(os.getcwd(), output_file)
11151115

11161116
with open(DL_PRODUCTS_ECSV, 'rb') as file:
11171117
zip_bytes = file.read()
@@ -1147,7 +1147,7 @@ def test_load_data_linking_parameter(monkeypatch, tmp_path):
11471147
now = datetime.datetime.now(datetime.timezone.utc)
11481148
output_file = 'datalink_output_' + now.strftime("%Y%m%dT%H%M%S") + '.zip'
11491149

1150-
path = Path(os.getcwd() + '/' + output_file)
1150+
path = Path(os.getcwd(), output_file)
11511151

11521152
with open(DL_PRODUCTS_VOT, 'rb') as file:
11531153
zip_bytes = file.read()
@@ -1184,7 +1184,7 @@ def test_load_data_linking_parameter_with_values(monkeypatch, tmp_path, linking_
11841184
now = datetime.datetime.now(datetime.timezone.utc)
11851185
output_file = 'datalink_output_' + now.strftime("%Y%m%dT%H%M%S") + '.zip'
11861186

1187-
path = Path(os.getcwd() + '/' + output_file)
1187+
path = Path(os.getcwd(), output_file)
11881188

11891189
with open(DL_PRODUCTS_VOT, 'rb') as file:
11901190
zip_bytes = file.read()
@@ -1196,7 +1196,7 @@ def load_data_monkeypatched(self, params_dict, output_file, verbose):
11961196
files = os.listdir(direc)
11971197
# Filtering only the files.
11981198
files = [f for f in files if
1199-
os.path.isfile(direc + '/' + f) and f.endswith(".zip") and f.startswith('datalink_output')]
1199+
Path(direc, f).is_file() and f.endswith(".zip") and f.startswith('datalink_output')]
12001200

12011201
assert len(files) == 1
12021202
datalink_output = files[0]
@@ -1209,7 +1209,7 @@ def load_data_monkeypatched(self, params_dict, output_file, verbose):
12091209
"DATA_STRUCTURE": "INDIVIDUAL",
12101210
"LINKING_PARAMETER": linking_param,
12111211
"USE_ZIP_ALWAYS": "true", }
1212-
assert output_file == os.getcwd() + '/' + datalink_output
1212+
assert output_file == str(Path(os.getcwd(), datalink_output))
12131213
assert verbose is True
12141214

12151215
monkeypatch.setattr(TapPlus, "load_data", load_data_monkeypatched)

0 commit comments

Comments
 (0)