nebius/SWE-bench-extra huggingface dataset:
Repository: bttner/kanelbulle

Issue:
Implement configuration
Requirements:
- Implement a possibility to load and store configuration data. 
- Respective unit tests for the introduced method/class should be provided as well.

Comments:

Patch:
diff --git a/kanelbulle/config/__init__.py b/kanelbulle/config/__init__.py
new file mode 100644
index 0000000..c3a0993
--- /dev/null
+++ b/kanelbulle/config/__init__.py
@@ -0,0 +1,1 @@
+"""Modules related to config"""
diff --git a/kanelbulle/config/config.py b/kanelbulle/config/config.py
new file mode 100644
index 0000000..863bed8
--- /dev/null
+++ b/kanelbulle/config/config.py
@@ -0,0 +1,32 @@
+"""Configuration storage."""
+
+import json
+
+
+class Container:
+    """Load and store configurations.
+
+    Attributes:
+        data: configuration data (dict).
+        error: error message (str).
+    """
+
+    def __init__(self):
+        self.data = None
+        self.error = "No error"
+        self.load()
+
+    def load(self):
+        """Load configurations from file."""
+        try:
+            with open("arms/config/config.json", 'r') as stream:
+                self.data = json.load(stream)
+        except OSError as e:
+            self.data = None
+            self.error = "OSError - " + str(e)
+        except ValueError as e:
+            self.data = None
+            self.error = "ValueError - " + str(e)
+
+
+var = Container()


Test patch:
diff --git a/tests/unit/test_config.py b/tests/unit/test_config.py
new file mode 100644
index 0000000..ddc30fd
--- /dev/null
+++ b/tests/unit/test_config.py
@@ -0,0 +1,35 @@
+"""Tests for kanelbulle.config.config."""
+
+from unittest import mock
+from kanelbulle.config import config
+
+
+def test_var_is_container():
+    """The variable var shall be an instance of the class Container."""
+    assert isinstance(config.var, config.Container) == True
+
+
+@mock.patch.object(config, 'open')
+def test_load_os_error(mock_open):
+    """IF a system-related error occurs, WHEN the configuration file is
+    loaded, THEN the respective error message shall be stored and the data
+    field shall be empty.
+    """
+    mock_open.side_effect = OSError
+    config.var.data = "OSError"
+    config.var.load()
+    assert (config.var.data is None) == True
+    assert ("OSError" in config.var.error) == True
+
+
+@mock.patch.object(config, 'open')
+def test_load_value_error(mock_open):
+    """IF a value error occurs, WHEN the configuration file is
+    loaded, THEN the respective error message shall be stored and the data
+    field shall be empty.
+    """
+    mock_open.side_effect = ValueError
+    config.var.data = "ValueError"
+    config.var.load()
+    assert (config.var.data is None) == True
+    assert ("ValueError" in config.var.error) == True