summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/examples.md26
-rw-r--r--docs/user_guide/compatibility.md8
-rwxr-xr-xexamples/convert_cache.py2
-rw-r--r--tests/conftest.py8
4 files changed, 22 insertions, 22 deletions
diff --git a/docs/examples.md b/docs/examples.md
index 779a64d..367581a 100644
--- a/docs/examples.md
+++ b/docs/examples.md
@@ -28,7 +28,7 @@ The following scripts can also be found in the
:end-line: 4
```
-:::{admonition} Example: `basic_sessions.py`
+:::{admonition} Example: [basic_sessions.py](https://github.com/reclosedev/requests-cache/blob/master/examples/basic_sessions.py)
:class: toggle
```{literalinclude} ../examples/basic_sessions.py
:lines: 6-
@@ -41,7 +41,7 @@ The following scripts can also be found in the
:end-line: 4
```
-:::{admonition} Example: `basic_patching.py`
+:::{admonition} Example: [basic_patching.py](https://github.com/reclosedev/requests-cache/blob/master/examples/basic_patching.py)
:class: toggle
```{literalinclude} ../examples/basic_patching.py
:lines: 6-
@@ -54,7 +54,7 @@ The following scripts can also be found in the
:end-line: 3
```
-:::{admonition} Example: `expiration.py`
+:::{admonition} Example: [expiration.py](https://github.com/reclosedev/requests-cache/blob/master/examples/expiration.py)
:class: toggle
```{literalinclude} ../examples/expiration.py
:lines: 5-
@@ -67,7 +67,7 @@ The following scripts can also be found in the
:end-line: 4
```
-:::{admonition} Example: `url_patterns.py`
+:::{admonition} Example: [url_patterns.py](https://github.com/reclosedev/requests-cache/blob/master/examples/url_patterns.py)
:class: toggle
```{literalinclude} ../examples/url_patterns.py
:lines: 6-
@@ -80,7 +80,7 @@ The following scripts can also be found in the
:end-line: 4
```
-:::{admonition} Example: `threads.py`
+:::{admonition} Example: [threads.py](https://github.com/reclosedev/requests-cache/blob/master/examples/threads.py)
:class: toggle
```{literalinclude} ../examples/threads.py
:lines: 6-
@@ -93,7 +93,7 @@ The following scripts can also be found in the
:end-line: 3
```
-:::{admonition} Example: `log_requests.py`
+:::{admonition} Example: [log_requests.py](https://github.com/reclosedev/requests-cache/blob/master/examples/log_requests.py)
:class: toggle
```{literalinclude} ../examples/log_requests.py
:lines: 5-
@@ -106,7 +106,7 @@ The following scripts can also be found in the
:end-line: 8
```
-:::{admonition} Example: `external_config.py`
+:::{admonition} Example: [external_config.py](https://github.com/reclosedev/requests-cache/blob/master/examples/external_config.py)
:class: toggle
```{literalinclude} ../examples/external_config.py
:lines: 10-
@@ -119,7 +119,7 @@ The following scripts can also be found in the
:end-line: 8
```
-:::{admonition} Example: `benchmark.py`
+:::{admonition} Example: [benchmark.py](https://github.com/reclosedev/requests-cache/blob/master/examples/benchmark.py)
:class: toggle
```{literalinclude} ../examples/benchmark.py
:lines: 10-
@@ -132,7 +132,7 @@ The following scripts can also be found in the
:end-line: 4
```
-:::{admonition} Example: `convert_cache.py`
+:::{admonition} Example: [convert_cache.py](https://github.com/reclosedev/requests-cache/blob/master/examples/convert_cache.py)
:class: toggle
```{literalinclude} ../examples/convert_cache.py
:lines: 6-
@@ -146,7 +146,7 @@ The following scripts can also be found in the
:end-line: 15
```
-:::{admonition} Example: `custom_request_matcher.py`
+:::{admonition} Example: [custom_request_matcher.py](https://github.com/reclosedev/requests-cache/blob/master/examples/custom_request_matcher.py)
:class: toggle
```{literalinclude} ../examples/custom_request_matcher.py
:lines: 17-
@@ -160,7 +160,7 @@ The following scripts can also be found in the
:end-line: 4
```
-:::{admonition} Example: `time_machine_backtesting.py`
+:::{admonition} Example: [time_machine_backtesting.py](https://github.com/reclosedev/requests-cache/blob/master/examples/time_machine_backtesting.py)
:class: toggle
```{literalinclude} ../examples/time_machine_backtesting.py
:lines: 6-
@@ -174,9 +174,9 @@ The following scripts can also be found in the
:end-line: 5
```
-:::{admonition} Example: `vcr.py`
+:::{admonition} Example: [vcr.py](https://github.com/reclosedev/requests-cache/blob/master/examples/vcr.py)
:class: toggle
```{literalinclude} ../examples/vcr.py
:lines: 7-
```
-::: \ No newline at end of file
+:::
diff --git a/docs/user_guide/compatibility.md b/docs/user_guide/compatibility.md
index fff338c..fcd5304 100644
--- a/docs/user_guide/compatibility.md
+++ b/docs/user_guide/compatibility.md
@@ -141,7 +141,7 @@ Or if you use a `CachedSession` object, you could replace it with a regular `Ses
If you want both caching and mocking features at the same time, you can attach requests-mock's
[adapter](https://requests-mock.readthedocs.io/en/latest/adapter.html) to a `CachedSession`:
-:::{admonition} Example: test_requests_mock_combine_cache.py
+:::{admonition} Example: `test_requests_mock_combine_cache.py`
:class: toggle
```{literalinclude} ../../tests/compat/test_requests_mock_combine_cache.py
```
@@ -157,7 +157,7 @@ This has the advantage of only using request-mock's behavior for
```
To turn that into a complete example:
-:::{admonition} Example: test_requests_mock_load_cache.py
+:::{admonition} Example: `test_requests_mock_load_cache.py`
:class: toggle
```{literalinclude} ../../tests/compat/test_requests_mock_load_cache.py
```
@@ -167,7 +167,7 @@ To turn that into a complete example:
Usage with the [responses](https://github.com/getsentry/responses) library is similar to the
requests-mock examples above.
-:::{admonition} Example: test_responses_load_cache.py
+:::{admonition} Example: `test_responses_load_cache.py`
:class: toggle
```{literalinclude} ../../tests/compat/test_responses_load_cache.py
```
@@ -177,7 +177,7 @@ requests-mock examples above.
If you would like to reuse your cached response data for unit tests, one option is to convert your
cache into a format compatible with VCR-vased libraries like
[vcrpy](https://github.com/kevin1024/vcrpy) and [betamax](https://github.com/betamaxpy/betamax).
-:::{admonition} Example: vcr.py
+:::{admonition} Example: `vcr.py`
:class: toggle
```{literalinclude} ../../examples/vcr.py
:lines: 7-
diff --git a/examples/convert_cache.py b/examples/convert_cache.py
index ed2a0a6..0ee2965 100755
--- a/examples/convert_cache.py
+++ b/examples/convert_cache.py
@@ -43,4 +43,4 @@ def convert_cache(*args, **kwargs):
# Example: convert a cache named 'demo_cache.sqlite' in the current directory
if __name__ == '__main__':
- convert_cache('demo_cache', backend='sqlite')
+ convert_cache('demo_cache.sqlite')
diff --git a/tests/conftest.py b/tests/conftest.py
index 7de9b6d..dc77368 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -12,7 +12,7 @@ import os
from datetime import datetime, timedelta
from functools import wraps
from logging import basicConfig, getLogger
-from os.path import abspath, dirname, join
+from pathlib import Path
from unittest.mock import MagicMock
from uuid import uuid4
@@ -66,9 +66,9 @@ MOCKED_URL_404 = 'http+mock://requests-cache.com/nonexistent'
MOCKED_URL_500 = 'http+mock://requests-cache.com/answer?q=this-statement-is-false'
MOCK_PROTOCOLS = ['mock://', 'http+mock://', 'https+mock://']
-PROJECT_DIR = abspath(dirname(dirname(__file__)))
-SAMPLE_DATA_DIR = join(PROJECT_DIR, 'tests', 'sample_data')
-SAMPLE_CACHE_FILES = [join(SAMPLE_DATA_DIR, path) for path in os.listdir(SAMPLE_DATA_DIR)]
+PROJECT_DIR = Path(__file__).parent.parent.absolute()
+SAMPLE_DATA_DIR = PROJECT_DIR / 'tests' / 'sample_data'
+SAMPLE_CACHE_FILES = list(SAMPLE_DATA_DIR.glob('sample.db.*'))
AWS_OPTIONS = {
'endpoint_url': 'http://localhost:8000',