3232
3333import pytest
3434
35+ from pyorbital .config import config
36+
3537LINE0 = "ISS (ZARYA)"
3638LINE1 = "1 25544U 98067A 08264.51782528 -.00002182 00000-0 -11606-4 0 2927"
3739LINE2 = "2 25544 51.6416 247.4627 0006703 130.5360 325.0288 15.72125391563537"
@@ -120,9 +122,9 @@ def test_read_tlefile_standard_platform_name(monkeypatch, fake_platforms_txt_fil
120122 from pyorbital import tlefile
121123
122124 path_to_platforms_txt_file = fake_platforms_txt_file .parent
123- monkeypatch .setenv ("PYORBITAL_CONFIG_PATH" , str (path_to_platforms_txt_file ))
124125
125- tle_n21 = tlefile .read ("NOAA-21" , str (fake_tlefile ))
126+ with config .set (config_path = str (path_to_platforms_txt_file )):
127+ tle_n21 = tlefile .read ("NOAA-21" , str (fake_tlefile ))
126128 assert tle_n21 .line1 == "1 54234U 22150A 23045.56664999 .00000332 00000+0 17829-3 0 9993"
127129 assert tle_n21 .line2 == "2 54234 98.7059 345.5113 0001226 81.6523 278.4792 14.19543871 13653"
128130
@@ -135,9 +137,9 @@ def test_read_tlefile_non_standard_platform_name(monkeypatch, fake_platforms_txt
135137 from pyorbital import tlefile
136138
137139 path_to_platforms_txt_file = fake_platforms_txt_file .parent
138- monkeypatch .setenv ("PYORBITAL_CONFIG_PATH" , str (path_to_platforms_txt_file ))
139140
140- tle_n20 = tlefile .read ("NOAA 20" , str (fake_tlefile ))
141+ with config .set (config_path = str (path_to_platforms_txt_file )):
142+ tle_n20 = tlefile .read ("NOAA 20" , str (fake_tlefile ))
141143
142144 assert tle_n20 .line1 == "1 43013U 17073A 23045.54907786 .00000253 00000+0 14081-3 0 9995"
143145 assert tle_n20 .line2 == "2 43013 98.7419 345.5839 0001610 80.3742 279.7616 14.19558274271576"
@@ -168,11 +170,11 @@ def test_read_tlefile_non_standard_platform_name_matching_start_of_name_in_tlefi
168170 from pyorbital import tlefile
169171
170172 path_to_platforms_txt_file = fake_platforms_txt_file .parent
171- monkeypatch .setenv ("PYORBITAL_CONFIG_PATH" , str (path_to_platforms_txt_file ))
172173
173- with pytest .raises (KeyError ) as exc_info :
174- with caplog .at_level (logging .DEBUG ):
175- _ = tlefile .read (sat_name , str (fake_tlefile ))
174+ with config .set (config_path = str (path_to_platforms_txt_file )):
175+ with pytest .raises (KeyError ) as exc_info :
176+ with caplog .at_level (logging .DEBUG ):
177+ _ = tlefile .read (sat_name , str (fake_tlefile ))
176178
177179 assert f"Found a possible match: { expected } ?" in caplog .text
178180 assert str (exc_info .value ) == f'"Found no TLE entry for \' { sat_name } \' "'
@@ -308,11 +310,10 @@ def test_get_config_path_ppp_config_set_and_pyorbital(caplog, monkeypatch):
308310 from pyorbital .tlefile import _get_config_path
309311
310312 pyorbital_config_dir = "/path/to/pyorbital/config/dir"
311- monkeypatch .setenv ("PYORBITAL_CONFIG_PATH" , pyorbital_config_dir )
312313 monkeypatch .setenv ("PPP_CONFIG_DIR" , "/path/to/old/mpop/config/dir" )
313-
314- with caplog .at_level (logging .WARNING ):
315- res = _get_config_path ()
314+ with config . set ( config_path = pyorbital_config_dir ):
315+ with caplog .at_level (logging .WARNING ):
316+ res = _get_config_path ()
316317
317318 assert res == pyorbital_config_dir
318319 assert caplog .text == ""
@@ -327,10 +328,10 @@ def test_get_config_path_pyorbital_ppp_missing(caplog, monkeypatch):
327328 from pyorbital .tlefile import _get_config_path
328329
329330 pyorbital_config_dir = "/path/to/pyorbital/config/dir"
330- monkeypatch .setenv ("PYORBITAL_CONFIG_PATH" , pyorbital_config_dir )
331331
332- with caplog .at_level (logging .DEBUG ):
333- res = _get_config_path ()
332+ with config .set (config_path = pyorbital_config_dir ):
333+ with caplog .at_level (logging .DEBUG ):
334+ res = _get_config_path ()
334335
335336 assert res == pyorbital_config_dir
336337 log_output = ("Path to the Pyorbital configuration (where e.g. " +
0 commit comments