summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJordan Cook <jordan.cook@pioneer.com>2022-05-21 15:00:29 -0500
committerJordan Cook <jordan.cook@pioneer.com>2022-05-30 11:37:22 -0400
commit352b64d0f6e616fa4393c221dda7550cd7928c74 (patch)
treeec0354281cb9be7a67ad48ed7661048928525981 /tests
parentee7adc177c3911f41e50c64c8c0511fbda8917a6 (diff)
downloadrequests-cache-352b64d0f6e616fa4393c221dda7550cd7928c74.tar.gz
Add a base model repr that excludes default values even if rich isn't installed
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/test_compat.py8
-rw-r--r--tests/unit/models/test_base.py6
2 files changed, 10 insertions, 4 deletions
diff --git a/tests/integration/test_compat.py b/tests/integration/test_compat.py
index 381b675..a49cf39 100644
--- a/tests/integration/test_compat.py
+++ b/tests/integration/test_compat.py
@@ -3,11 +3,11 @@ from shutil import copyfile
import pytest
from requests_cache import CachedSession
-from tests.conftest import HTTPBIN_FORMATS, SAMPLE_CACHE_FILES
+from tests.conftest import HTTPBIN_FORMATS, SAMPLE_CACHE_FILES, httpbin
# TODO: Debug why this sometimes fails (mostly just on GitHub Actions)
-@pytest.mark.flaky(reruns=3)
+# @pytest.mark.flaky(reruns=3)
@pytest.mark.parametrize('db_path', SAMPLE_CACHE_FILES)
def test_version_upgrade(db_path, tempfile_path):
"""Load SQLite cache files created with older versions of requests-cache.
@@ -21,5 +21,5 @@ def test_version_upgrade(db_path, tempfile_path):
session = CachedSession(tempfile_path)
for response_format in HTTPBIN_FORMATS:
- session.get(f'https://httpbin.org/{response_format}').from_cache
- assert session.get(f'https://httpbin.org/{response_format}').from_cache is True
+ session.get(httpbin(response_format)).from_cache
+ assert session.get(httpbin(response_format)).from_cache is True
diff --git a/tests/unit/models/test_base.py b/tests/unit/models/test_base.py
index 25a4a23..d91ddc2 100644
--- a/tests/unit/models/test_base.py
+++ b/tests/unit/models/test_base.py
@@ -24,3 +24,9 @@ def test_rich_mixin():
('int_attr', 1, None),
('list_attr', ['a', 'b'], []),
]
+
+
+def test_repr():
+ """Test that regular __repr__ excludes default values"""
+ assert repr(DemoModel() == 'DemoModel()')
+ assert repr(DemoModel(str_attr='str') == "DemoModel(str_attr='str')")