Skip to content

Commit

Permalink
Bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadowXBoss696 committed Apr 18, 2024
1 parent f3a1e31 commit d847135
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
4 changes: 1 addition & 3 deletions fastboot/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __setattr__(self, name: str, value: Any) -> None:
else:
super().__setattr__(name, value)

def __str__(self) -> str:
def __repr__(self) -> str:
lines = []
kmax: int = max(len(k) for k in self._store)
vmax: int = 30
Expand All @@ -51,8 +51,6 @@ def __str__(self) -> str:

return os.linesep.join(lines)

__repr__ = __str__


class Preference(metaclass=ABCMeta):
"""
Expand Down
22 changes: 22 additions & 0 deletions tests/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,19 @@ class DummyPreferenceWithCallableValue(Preference):
This is a dummy preference with a method passed as value
"""

class DummyPreferenceWithLargeValue(Preference):
name = "dummy_preference_with_large_value"
default = """\
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et
dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt
mollit anim id est laborum.
"""
desc = """\
This is a dummy preference with a large text as value
"""


def teardown_module(module):
"""teardown any state that was previously setup with a setup_module method."""
Expand Down Expand Up @@ -117,3 +130,12 @@ def test_print_app_preference(preferences: AppPreferences) -> None:
assert len(output) > 0, "No output printed"
assert "dummy_pref" in output, "Dummy preference key is not printed correctly"
assert "default_value" in output or "new_value" in output, "Dummy preference value is not printed correctly"

print()

for pref in preferences._store.values():
output = repr(pref)
print(output)

assert pref.__class__.__name__ in output, "Preference definitions class name is not printed properly."
assert str(pref._value) in output, "Preference definitions current value is not printed properly."

0 comments on commit d847135

Please sign in to comment.