From 982faaf7bc71e456961cce71ec4632a8ba3f845e Mon Sep 17 00:00:00 2001 From: Marvin Poul Date: Tue, 23 Jul 2024 12:10:34 +0200 Subject: [PATCH] Add comments for windows --- pyiron_snippets/resources.py | 4 ++++ tests/unit/test_resources.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pyiron_snippets/resources.py b/pyiron_snippets/resources.py index 3972e2a..ae6efe6 100644 --- a/pyiron_snippets/resources.py +++ b/pyiron_snippets/resources.py @@ -202,6 +202,9 @@ class ExecutableResolver(AbstractResolver): and have the executable bit set. :meth:`.search` yields tuples of version strings and full paths to the executable instead of plain strings. + Except on windows results are filtered to make sure all returned scripts have the executable bit set. + When the bit is not set, a warning is printed. + >>> exe = ExecutableResolver(..., "lammps") >>> exe.list() # doctest: +SKIP [ @@ -253,6 +256,7 @@ def _search(self, name): def cond(path): isfile = os.path.isfile(path) + # HINT: this is always True on windows isexec = os.access( path, os.X_OK, effective_ids=os.access in os.supports_effective_ids ) diff --git a/tests/unit/test_resources.py b/tests/unit/test_resources.py index b2da759..de1fda7 100644 --- a/tests/unit/test_resources.py +++ b/tests/unit/test_resources.py @@ -56,10 +56,10 @@ def test_executable(self): for suffix in (None, "sh", "bat"): with self.subTest(suffix=suffix): res = ExecutableResolver([self.res1], code="code1", module="module1", suffix=suffix) + # Windows always reports the exec bit as set, so skip those tests there if os.name != "nt": with self.assertLogs(logger, level="WARNING"): res.list() - # no exec bits are present on windows it seems self.assertNotIn("versionnonexec", res.available_versions, "ExecutableResolver must not list scripts that are not executable.") self.assertNotIn("wrong_format", res.available_versions,