Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure to add trailing slash on paths #779

Merged
merged 3 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading