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

Files: Fix windows compatibility #1643

Merged
merged 4 commits into from
Sep 16, 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
7 changes: 3 additions & 4 deletions pyiron_base/jobs/job/extension/files.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import posixpath
from itertools import islice
from typing import Generator, List, Optional, Union

Expand Down Expand Up @@ -100,7 +99,7 @@ class FileBrowser:
__slots__ = ("_working_directory",)

def __init__(self, working_directory: str):
self._working_directory = working_directory
self._working_directory = os.path.abspath(os.path.expanduser(working_directory))

def _get_file_dict(self) -> dict:
return {
Expand Down Expand Up @@ -150,12 +149,12 @@ def __getitem__(self, item: str) -> Union[File, "FileBrowser"]:
working_directory=self._working_directory,
include_archive=False,
):
return File(posixpath.join(self._working_directory, item))
return File(os.path.join(self._working_directory, item))
elif item in _working_directory_list_files(
working_directory=self._working_directory,
include_archive=True,
):
return File(posixpath.join(self._working_directory, item))
return File(os.path.join(self._working_directory, item))
else:
raise FileNotFoundError(item)

Expand Down
5 changes: 1 addition & 4 deletions tests/unit/flex/test_executablecontainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,7 @@ def test_job_files(self):
"error.out",
)
)
if os.name != "nt":
self.assertEqual(str(job.files.error_out), output_file_path)
else:
self.assertEqual(job.files.error_out, output_file_path.replace("\\", "/"))
self.assertEqual(str(job.files.error_out), output_file_path)

def test_create_job_factory_typeerror(self):
create_catjob = create_job_factory(
Expand Down
5 changes: 3 additions & 2 deletions tests/unit/flex/test_wrap_executable.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import posixpath
from pyiron_base._tests import TestWithProject


Expand Down Expand Up @@ -30,7 +29,9 @@ def test_python_version(self):
self.assertTrue(python_version_step.status.finished)
self.assertEqual(
python_version_step.files.error_out,
posixpath.join(python_version_step.working_directory, "error.out"),
os.path.join(
os.path.abspath(python_version_step.working_directory), "error.out"
),
)

def test_cat(self):
Expand Down
Loading