Skip to content

Commit

Permalink
Make sure to add trailing slash on paths (#779)
Browse files Browse the repository at this point in the history
* Make sure to add trailing slash on paths
  • Loading branch information
DominicOram authored Sep 6, 2024
1 parent 350ca72 commit e8f8b62
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/dodal/devices/detector/detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def _parse_detector_size_constants(cls, det_type: str) -> DetectorSizeConstants:
def _parse_directory(cls, directory: str | Path) -> str:
path = Path(directory)
assert path.is_dir()
return str(path)
return f"{path}/"

def get_beam_position_mm(self, detector_distance: float) -> tuple[float, float]:
x_beam_mm = self.beam_xy_converter.get_beam_xy_from_det_dist(
Expand Down
2 changes: 1 addition & 1 deletion src/dodal/devices/util/lookup_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ async def energy_distance_table(lookup_table_path: str) -> np.ndarray:

# Slight cheat to make the file IO async, numpy doesn't do any real IO now, just
# decodes the text
async with aiofiles.open(lookup_table_path, "r") as stream:
async with aiofiles.open(lookup_table_path) as stream:
raw_table = await stream.read()
return loadtxt(StringIO(raw_table), comments=["#", "Units"])

Expand Down
4 changes: 2 additions & 2 deletions tests/devices/unit_tests/detector/test_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def create_det_params_with_dir_and_prefix(directory: str | Path, prefix="test"):
def test_if_string_provided_check_is_dir(tmp_path: Path):
assert not (_dir := str(tmp_path)).endswith("/")
params = create_det_params_with_dir_and_prefix(_dir)
assert params.directory == str(tmp_path)
assert params.directory == f"{tmp_path}/"
file_path = tmp_path / "foo.h5"
file_path.touch()
with pytest.raises(ValidationError):
Expand All @@ -37,7 +37,7 @@ def test_if_string_provided_check_is_dir(tmp_path: Path):

def test_if_path_provided_check_is_dir(tmp_path: Path):
params = create_det_params_with_dir_and_prefix(tmp_path)
assert params.directory == str(tmp_path)
assert params.directory == f"{tmp_path}/"
file_path = tmp_path / "foo.h5"
file_path.touch()
with pytest.raises(ValidationError):
Expand Down

0 comments on commit e8f8b62

Please sign in to comment.