Download tasks/format-code-task-000041/tests/test.patch from FineEnvs/MiMo-V2.6-RL-harbor-code: direct link, hf CLI and curl.
- Browser
- Download file 3.83 kB
-
https://huggingface.co/datasets/FineEnvs/MiMo-V2.6-RL-harbor-code/resolve/main/tasks/format-code-task-000041/tests/test.patch
- Command line
-
hf download hf://datasets/FineEnvs/MiMo-V2.6-RL-harbor-code/tasks/format-code-task-000041/tests/test.patch
-
curl -L -o test.patch https://huggingface.co/datasets/FineEnvs/MiMo-V2.6-RL-harbor-code/resolve/main/tasks/format-code-task-000041/tests/test.patch
3.83 kB
| diff --git a/test_commands.json b/test_commands.json | |
| new file mode 100644 | |
| index 00000000..96be81d1 | |
| --- /dev/null | |
| +++ b/test_commands.json | |
| +{ | |
| + "test_commands": ["python -m pytest tests/units/test_core.py::TestCoreConfDirOnReadOnlyFS -v"] | |
| +} | |
| diff --git a/tests/units/test_core.py b/tests/units/test_core.py | |
| index f5f118c4..45a7e1be 100644 | |
| --- a/tests/units/test_core.py | |
| +++ b/tests/units/test_core.py | |
| class TestCoreProductAlias(TestCoreBase): | |
| # not existing product type | |
| with self.assertRaises(NoMatchingProductType): | |
| self.dag.get_product_type_from_alias("JUST_A_TYPE") | |
| + | |
| + | |
| +class TestCoreConfDirOnReadOnlyFS(unittest.TestCase): | |
| + """Tests for EODataAccessGateway construction on a read-only filesystem | |
| + (AWS Lambda issue: $HOME is read-only).""" | |
| + | |
| + def setUp(self): | |
| + import tempfile as _tempfile | |
| + | |
| + self._tempfile = _tempfile | |
| + | |
| + self.tmp_home_dir = TemporaryDirectory() | |
| + self.expanduser_patcher = mock.patch( | |
| + "os.path.expanduser", | |
| + autospec=True, | |
| + return_value=self.tmp_home_dir.name, | |
| + ) | |
| + self.expanduser_patcher.start() | |
| + | |
| + | |
| + self._saved_env = {} | |
| + for k in ("EODAG_CFG_DIR", "EODAG_CFG_FILE", "EODAG_LOCS_CFG_FILE"): | |
| + self._saved_env[k] = os.environ.pop(k, None) | |
| + | |
| + | |
| + self._cleanup_paths = [ | |
| + os.path.join(self._tempfile.gettempdir(), ".config", "eodag"), | |
| + ] | |
| + | |
| + def tearDown(self): | |
| + self.expanduser_patcher.stop() | |
| + self.tmp_home_dir.cleanup() | |
| + for k, v in self._saved_env.items(): | |
| + if v is None: | |
| + os.environ.pop(k, None) | |
| + else: | |
| + os.environ[k] = v | |
| + | |
| + logger = logging.getLogger("eodag") | |
| + logger.handlers = [] | |
| + logger.level = 0 | |
| + | |
| + for p in self._cleanup_paths: | |
| + if os.path.isdir(p): | |
| + shutil.rmtree(p, ignore_errors=True) | |
| + | |
| + def test_default_conf_dir_uses_home(self): | |
| + """Regression: with no overrides, conf_dir defaults to ~/.config/eodag | |
| + and the directory is available.""" | |
| + dag = EODataAccessGateway() | |
| + expected = os.path.join(self.tmp_home_dir.name, ".config", "eodag") | |
| + self.assertEqual(dag.conf_dir, expected) | |
| + self.assertTrue(os.path.isdir(dag.conf_dir)) | |
| + | |
| + def test_constructor_does_not_raise_on_readonly_home(self): | |
| + """Core user scenario from the issue: ``EODataAccessGateway()`` with no | |
| + arguments must not raise ``OSError`` when ``$HOME`` (and any path | |
| + derived from it) lives on a read-only filesystem, as is the case on | |
| + AWS Lambda. The fix may live at any layer (catch+fallback, lazy | |
| + creation, low-level swallow, ...): all that the user observes is the | |
| + absence of the exception.""" | |
| + import errno as _errno | |
| + | |
| + real_os_makedirs = os.makedirs | |
| + home = self.tmp_home_dir.name | |
| + | |
| + def fake_os_makedirs(path, *args, **kwargs): | |
| + | |
| + if path == home or path.startswith(home + os.sep): | |
| + raise OSError( | |
| + _errno.EROFS, "Read-only file system", path | |
| + ) | |
| + return real_os_makedirs(path, *args, **kwargs) | |
| + | |
| + with mock.patch("os.makedirs", side_effect=fake_os_makedirs): | |
| + | |
| + EODataAccessGateway() | |
| diff --git a/mimo_test_command.sh b/mimo_test_command.sh | |
| new file mode 100755 | |
| --- /dev/null | |
| +++ b/mimo_test_command.sh | |
| +#!/usr/bin/env bash | |
| + | |
| +set -uo pipefail | |
| +cd /testbed | |
| +rc=0 | |
| +python -m pytest -v -rA tests/units/test_core.py::TestCoreConfDirOnReadOnlyFS::test_default_conf_dir_uses_home tests/units/test_core.py::TestCoreConfDirOnReadOnlyFS::test_constructor_does_not_raise_on_readonly_home | |
| +rc=$(( rc | $? )) | |
| +exit $rc | |