diff --git a/tests/test_TiO2.py b/tests/test_TiO2.py index 95b115d1..6d586fab 100644 --- a/tests/test_TiO2.py +++ b/tests/test_TiO2.py @@ -14,7 +14,7 @@ @fixture -def datadir(tmpdir, request): +def datadir(tmp_path, request): """ Fixture responsible for searching a folder with the same name of test module and, if available, moving all contents to a temporary directory so @@ -24,26 +24,24 @@ def datadir(tmpdir, request): test_dir, _ = os.path.splitext(filename) if os.path.isdir(test_dir): - rmtree(tmpdir) - copytree(test_dir, str(tmpdir)) + rmtree(tmp_path) + copytree(test_dir, str(tmp_path)) - return tmpdir + return tmp_path @fixture def meas_data(datadir): """Fixture for getting the reference measurement data from the file.""" return ( - elli.read_spectraray_rho(datadir.join("TiO2_400cycles.txt")) - .loc[70.06] - .loc[400:800] + elli.read_spectraray_rho(datadir / "TiO2_400cycles.txt").loc[70.06].loc[400:800] ) @fixture def si_dispersion(datadir): """Fixture to load the silicon dispersion from file.""" - sr = elli.TableSpectraRay(datadir) + sr = elli.TableSpectraRay(f"{datadir}{os.sep}") silicon = elli.IsotropicMaterial(sr.load_dispersion_table(f"{os.sep}Si_Aspnes.mat")) return silicon diff --git a/tests/test_dispersions.py b/tests/test_dispersions.py index c111c126..58f82562 100644 --- a/tests/test_dispersions.py +++ b/tests/test_dispersions.py @@ -16,16 +16,16 @@ @fixture -def datadir(tmpdir, request): +def datadir(tmp_path, request): """Fixture for providing the dispersion prototype folder""" filename = request.module.__file__ test_dir, _ = os.path.splitext(filename) if os.path.isdir(test_dir): - rmtree(tmpdir) - copytree(test_dir, str(tmpdir)) + rmtree(tmp_path) + copytree(test_dir, str(tmp_path)) - return tmpdir + return tmp_path def test_constant_refr_index(): @@ -68,7 +68,7 @@ def test_regression_dispersions_default(datadir): lbda = np.linspace(400, 1000, 500) for dispersion in dispersions: - prototype = pd.read_csv(datadir.join(f"{dispersion}_default.csv"), index_col=0) + prototype = pd.read_csv(datadir / f"{dispersion}_default.csv", index_col=0) disp = elli.DispersionFactory.get_dispersion(dispersion) assert_frame_equal(prototype, disp.get_dielectric_df(lbda)) @@ -196,9 +196,7 @@ def test_regression_dispersions_custom_values(datadir): for dispersion in dispersions: disp_name = dispersion.get("name") - prototype = pd.read_csv( - datadir.join(f"{disp_name}_custom_values.csv"), index_col=0 - ) + prototype = pd.read_csv(datadir / f"{disp_name}_custom_values.csv", index_col=0) disp = elli.DispersionFactory.get_dispersion( disp_name, **dispersion.get("single_params") )