1- import os
21import shutil
3- from os import path
2+ from pathlib import Path
43
54import pytest
65import autolens as al
76from autolens .analysis import plotter as vis
87
9- directory = path . dirname ( path . realpath ( __file__ ))
8+ directory = Path ( __file__ ). resolve (). parent
109
1110
1211@pytest .fixture (name = "plot_path" )
1312def make_plotter_plotter_setup ():
14- return path . join ( "{}" . format ( directory ), "files" )
13+ return directory / "files"
1514
1615
1716def test__tracer (masked_imaging_7x7 , tracer_x2_plane_7x7 , plot_path , plot_patch ):
18- if os . path . exists (plot_path ):
17+ if plot_path . exists ():
1918 shutil .rmtree (plot_path )
2019
2120 plotter = vis .Plotter (image_path = plot_path )
@@ -25,21 +24,21 @@ def test__tracer(masked_imaging_7x7, tracer_x2_plane_7x7, plot_path, plot_patch)
2524 grid = masked_imaging_7x7 .grids .lp ,
2625 )
2726
28- assert path . join (plot_path , "galaxies_images.png" ) in plot_patch .paths
27+ assert str (plot_path / "galaxies_images.png" ) in plot_patch .paths
2928
3029 image = al .ndarray_via_fits_from (
31- file_path = path . join ( plot_path , "tracer.fits" ) , hdu = 0
30+ file_path = plot_path / "tracer.fits" , hdu = 0
3231 )
3332
3433 assert image .shape == (5 , 5 )
3534
3635
3736def test__image_with_positions (image_7x7 , positions_x2 , plot_path , plot_patch ):
38- if os . path . exists (plot_path ):
37+ if plot_path . exists ():
3938 shutil .rmtree (plot_path )
4039
4140 plotter = vis .Plotter (image_path = plot_path )
4241
4342 plotter .image_with_positions (image = image_7x7 , positions = positions_x2 )
4443
45- assert path . join (plot_path , "image_with_positions.png" ) in plot_patch .paths
44+ assert str (plot_path / "image_with_positions.png" ) in plot_patch .paths
0 commit comments