]> Repositories - Adafruit_Blinka-hackapet.git/commitdiff
Remove return_toml param
authorJustin Myers <justmobilize@users.noreply.github.com>
Tue, 4 Mar 2025 16:28:29 +0000 (08:28 -0800)
committerJustin Myers <justmobilize@users.noreply.github.com>
Tue, 4 Mar 2025 16:28:29 +0000 (08:28 -0800)
src/adafruit_blinka/__init__.py
tests/test_load_settings_toml.py

index e3cc50c69a8570bae983c043283c58aa048a7edb..38ccec42aaff5ced24d1bbbc3fc9477ebdd94402 100755 (executable)
@@ -81,7 +81,7 @@ class Lockable(ContextManaged):
             self._locked = False
 
 
-def load_settings_toml(*, return_toml=False):
+def load_settings_toml():
     """Load values from settings.toml into os.environ, so that os.getenv returns them."""
     if not os.path.isfile("settings.toml"):
         raise FileNotFoundError("settings.toml not cound in current directory.")
@@ -111,9 +111,7 @@ def load_settings_toml(*, return_toml=False):
         os.environ[key] = str(value)
         print(f" - {key} added")
 
-    if return_toml:
-        return settings
-    return None
+    return settings
 
 
 def patch_system():
index da01555800086adf311c309121b3dc51b9f95bf9..4257108da849db9d610cdacc9177d89d9ca32957 100644 (file)
@@ -79,7 +79,7 @@ class TestLoadSettingsToml:
         with pytest.raises(
             FileNotFoundError, match="settings.toml not cound in current directory."
         ):
-            load_settings_toml(return_toml=True)
+            load_settings_toml()
 
     @mock.patch("adafruit_blinka.os.path.isfile", mock.Mock(return_value=True))
     @mock.patch("builtins.open", mock.mock_open(read_data=INVALID_TOML))
@@ -87,7 +87,7 @@ class TestLoadSettingsToml:
         with pytest.raises(
             tomllib.TOMLDecodeError, match="Error with settings.toml file."
         ):
-            load_settings_toml(return_toml=True)
+            load_settings_toml()
 
     @mock.patch("adafruit_blinka.os.path.isfile", mock.Mock(return_value=True))
     @mock.patch(
@@ -97,7 +97,7 @@ class TestLoadSettingsToml:
         with pytest.raises(
             ValueError, match="The types: 'dict' are not supported in settings.toml."
         ):
-            load_settings_toml(return_toml=True)
+            load_settings_toml()
 
     @mock.patch("adafruit_blinka.os.path.isfile", mock.Mock(return_value=True))
     @mock.patch(
@@ -107,7 +107,7 @@ class TestLoadSettingsToml:
         with pytest.raises(
             ValueError, match="The types: 'list' are not supported in settings.toml."
         ):
-            load_settings_toml(return_toml=True)
+            load_settings_toml()
 
     @mock.patch("adafruit_blinka.os.path.isfile", mock.Mock(return_value=True))
     @mock.patch(
@@ -118,7 +118,7 @@ class TestLoadSettingsToml:
             ValueError,
             match="The types: 'dict, list' are not supported in settings.toml.",
         ):
-            load_settings_toml(return_toml=True)
+            load_settings_toml()
 
     @mock.patch("adafruit_blinka.os.path.isfile", mock.Mock(return_value=True))
     @mock.patch(
@@ -129,7 +129,7 @@ class TestLoadSettingsToml:
         with pytest.raises(
             ValueError, match="The types: 'dict' are not supported in settings.toml."
         ):
-            load_settings_toml(return_toml=True)
+            load_settings_toml()
 
     @mock.patch("adafruit_blinka.os.path.isfile", mock.Mock(return_value=True))
     @mock.patch("builtins.open", mock.mock_open(read_data=VALID_TOML))
@@ -138,19 +138,7 @@ class TestLoadSettingsToml:
         for key in CONVERTED_TOML:
             assert os.getenv(key) is None
 
-        assert load_settings_toml() is None
-
-        for key, value in CONVERTED_TOML.items():
-            assert os.getenv(key) == str(value)
-
-    @mock.patch("adafruit_blinka.os.path.isfile", mock.Mock(return_value=True))
-    @mock.patch("builtins.open", mock.mock_open(read_data=VALID_TOML))
-    @mock.patch.dict(os.environ, {}, clear=True)
-    def test_returns_data_when_asked(self):
-        for key in CONVERTED_TOML:
-            assert os.getenv(key) is None
-
-        assert load_settings_toml(return_toml=True) == CONVERTED_TOML
+        assert load_settings_toml() == CONVERTED_TOML
 
         for key, value in CONVERTED_TOML.items():
             assert os.getenv(key) == str(value)