Skip to content

Commit

Permalink
Merge pull request #10 from TabulateJarl8/fix-first-startup-config
Browse files Browse the repository at this point in the history
Fix config read error on first startup when config doesn't exist
  • Loading branch information
TabulateJarl8 authored Feb 12, 2024
2 parents a946ad5 + f18a109 commit cbe8597
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "vapor-steam"
version = "1.5.1"
version = "1.5.2"
description = "TUI program to check the ProtonDB compatibility of all the games of a Steam user."
authors = ["TabulateJarl8 <[email protected]>"]
license = "GPLv3"
Expand Down
3 changes: 1 addition & 2 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ def test_read_config_os_error(config):

def test_read_config_non_existent_file(config):
config._config_path.exists_bool = False
with pytest.raises(ConfigReadError):
config.read_config()
assert config.read_config()._config_data._sections == {}


def test_write_config_non_existent_file(config):
Expand Down
8 changes: 4 additions & 4 deletions vapor/config_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ def get_value(self, key: str) -> str:
return ''

def read_config(self) -> Self:
"""Read the config from the file location.
"""Read the config from the file location. If file does not exist, a
blank config is loaded.
Returns:
Self
Expand All @@ -91,9 +92,8 @@ def read_config(self) -> Self:
"""
try:
self._config_data = ConfigParser()
if not self._config_path.exists():
raise ConfigReadError(f'File `{self._config_path}` does not exist')
self._config_data.read(self._config_path)
if self._config_path.exists():
self._config_data.read(self._config_path)

except Exception as e:
raise ConfigReadError from e
Expand Down

0 comments on commit cbe8597

Please sign in to comment.