Skip to content

Commit 046217c

Browse files
committed
Remove return_toml param
1 parent 5b94da4 commit 046217c

File tree

2 files changed

+9
-23
lines changed

2 files changed

+9
-23
lines changed

src/adafruit_blinka/__init__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def unlock(self):
8181
self._locked = False
8282

8383

84-
def load_settings_toml(*, return_toml=False):
84+
def load_settings_toml():
8585
"""Load values from settings.toml into os.environ, so that os.getenv returns them."""
8686
if not os.path.isfile("settings.toml"):
8787
raise FileNotFoundError("settings.toml not cound in current directory.")
@@ -111,9 +111,7 @@ def load_settings_toml(*, return_toml=False):
111111
os.environ[key] = str(value)
112112
print(f" - {key} added")
113113

114-
if return_toml:
115-
return settings
116-
return None
114+
return settings
117115

118116

119117
def patch_system():

tests/test_load_settings_toml.py

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,15 @@ def test_raises_with_no_file(self):
7979
with pytest.raises(
8080
FileNotFoundError, match="settings.toml not cound in current directory."
8181
):
82-
load_settings_toml(return_toml=True)
82+
load_settings_toml()
8383

8484
@mock.patch("adafruit_blinka.os.path.isfile", mock.Mock(return_value=True))
8585
@mock.patch("builtins.open", mock.mock_open(read_data=INVALID_TOML))
8686
def test_raises_with_invalid_file(self):
8787
with pytest.raises(
8888
tomllib.TOMLDecodeError, match="Error with settings.toml file."
8989
):
90-
load_settings_toml(return_toml=True)
90+
load_settings_toml()
9191

9292
@mock.patch("adafruit_blinka.os.path.isfile", mock.Mock(return_value=True))
9393
@mock.patch(
@@ -97,7 +97,7 @@ def test_raises_with_invalid_file_dict(self):
9797
with pytest.raises(
9898
ValueError, match="The types: 'dict' are not supported in settings.toml."
9999
):
100-
load_settings_toml(return_toml=True)
100+
load_settings_toml()
101101

102102
@mock.patch("adafruit_blinka.os.path.isfile", mock.Mock(return_value=True))
103103
@mock.patch(
@@ -107,7 +107,7 @@ def test_raises_with_invalid_file_list(self):
107107
with pytest.raises(
108108
ValueError, match="The types: 'list' are not supported in settings.toml."
109109
):
110-
load_settings_toml(return_toml=True)
110+
load_settings_toml()
111111

112112
@mock.patch("adafruit_blinka.os.path.isfile", mock.Mock(return_value=True))
113113
@mock.patch(
@@ -118,7 +118,7 @@ def test_raises_with_invalid_file_many(self):
118118
ValueError,
119119
match="The types: 'dict, list' are not supported in settings.toml.",
120120
):
121-
load_settings_toml(return_toml=True)
121+
load_settings_toml()
122122

123123
@mock.patch("adafruit_blinka.os.path.isfile", mock.Mock(return_value=True))
124124
@mock.patch(
@@ -129,7 +129,7 @@ def test_raises_with_invalid_file_nested(self):
129129
with pytest.raises(
130130
ValueError, match="The types: 'dict' are not supported in settings.toml."
131131
):
132-
load_settings_toml(return_toml=True)
132+
load_settings_toml()
133133

134134
@mock.patch("adafruit_blinka.os.path.isfile", mock.Mock(return_value=True))
135135
@mock.patch("builtins.open", mock.mock_open(read_data=VALID_TOML))
@@ -138,19 +138,7 @@ def test_returns_data(self):
138138
for key in CONVERTED_TOML:
139139
assert os.getenv(key) is None
140140

141-
assert load_settings_toml() is None
142-
143-
for key, value in CONVERTED_TOML.items():
144-
assert os.getenv(key) == str(value)
145-
146-
@mock.patch("adafruit_blinka.os.path.isfile", mock.Mock(return_value=True))
147-
@mock.patch("builtins.open", mock.mock_open(read_data=VALID_TOML))
148-
@mock.patch.dict(os.environ, {}, clear=True)
149-
def test_returns_data_when_asked(self):
150-
for key in CONVERTED_TOML:
151-
assert os.getenv(key) is None
152-
153-
assert load_settings_toml(return_toml=True) == CONVERTED_TOML
141+
assert load_settings_toml() == CONVERTED_TOML
154142

155143
for key, value in CONVERTED_TOML.items():
156144
assert os.getenv(key) == str(value)

0 commit comments

Comments
 (0)