[Git][debian-gis-team/pytest-recording][master] 5 commits: New upstream version 0.13.2

Antonio Valentino (@antonio.valentino) gitlab at salsa.debian.org
Sat Jul 13 10:09:22 BST 2024



Antonio Valentino pushed to branch master at Debian GIS Project / pytest-recording


Commits:
bb965072 by Antonio Valentino at 2024-07-13T09:00:03+00:00
New upstream version 0.13.2
- - - - -
28450037 by Antonio Valentino at 2024-07-13T09:00:04+00:00
Update upstream source from tag 'upstream/0.13.2'

Update to upstream version '0.13.2'
with Debian dir ac76eb1f3dd604c3fdefcb3184e2aa0d2d89d396
- - - - -
27c99dc8 by Antonio Valentino at 2024-07-13T09:00:49+00:00
New upstream release

- - - - -
8a1577e9 by Antonio Valentino at 2024-07-13T09:04:15+00:00
Update dates in d/copyright

- - - - -
9b593f70 by Antonio Valentino at 2024-07-13T09:05:31+00:00
Set distribution to unstable

- - - - -


11 changed files:

- .github/workflows/build.yml
- CONTRIBUTING.rst
- README.rst
- debian/changelog
- debian/copyright
- docs/changelog.rst
- pyproject.toml
- src/pytest_recording/_vcr.py
- src/pytest_recording/hooks.py
- src/pytest_recording/plugin.py
- src/pytest_recording/utils.py


Changes:

=====================================
.github/workflows/build.yml
=====================================
@@ -96,6 +96,6 @@ jobs:
       - run: coverage xml -i
 
       - name: Upload coverage to Codecov
-        uses: codecov/codecov-action at v3.1.4
+        uses: codecov/codecov-action at v4.5.0
         with:
           file: ./coverage.xml


=====================================
CONTRIBUTING.rst
=====================================
@@ -42,7 +42,7 @@ It would be awesome if you can submit a failing test that demonstrates the probl
 .. _fixbugs:
 
 Submitting Pull Requests
------------------------
+------------------------
 
 #. Fork the repository.
 #. Enable and install `pre-commit <https://pre-commit.com>`_ to ensure style-guides and code checks are followed.


=====================================
README.rst
=====================================
@@ -13,6 +13,18 @@ Features
 - Network access blocking;
 - The ``rewrite`` recording mode that rewrites cassettes from scratch.
 
+Installation
+------------
+
+This project can be installed via pip:
+
+.. code:: bash
+
+    pip install pytest-recording
+
+⚠️This project is not compatible with `pytest-vcr`, make sure to uninstall before ⚠️
+
+
 Usage
 -----
 
@@ -38,6 +50,15 @@ Usage
         assert requests.get("http://httpbin.org/get").text == '{"get": true}'
         assert requests.get("http://httpbin.org/ip").text == '{"ip": true}'
 
+    # Make assertions based on the cassette calls/responses:
+    @pytest.mark.vcr
+    def test_call_count(vcr):
+        assert requests.get("http://httpbin.org/get").text == '{"get": true}'
+        assert requests.get("http://httpbin.org/ip").text == '{"ip": true}'
+        # See https://vcrpy.readthedocs.io/en/latest/advanced.html for more info
+        # about the Cassette object:
+        assert vcr.play_count == 2
+
 Run your tests:
 
 .. code:: bash


=====================================
debian/changelog
=====================================
@@ -1,3 +1,10 @@
+pytest-recording (0.13.2-1) unstable; urgency=medium
+
+  * New upstream release.
+  * Update dates in d/copyright.
+
+ -- Antonio Valentino <antonio.valentino at tiscali.it>  Sat, 13 Jul 2024 09:04:19 +0000
+
 pytest-recording (0.13.1-1) unstable; urgency=medium
 
   * New upstream release.


=====================================
debian/copyright
=====================================
@@ -8,7 +8,7 @@ Copyright: 2019, Kiwi.com
 License: Expat
 
 Files: debian/*
-Copyright: 2023, Antonio Valentino <antonio.valentino at tiscali.it>
+Copyright: 2023-2024, Antonio Valentino <antonio.valentino at tiscali.it>
 License: Expat
 
 License: Expat


=====================================
docs/changelog.rst
=====================================
@@ -6,6 +6,12 @@ Changelog
 `Unreleased`_
 -------------
 
+`0.13.2`_ - 2024-07-09
+----------------------
+
+- Add lazy loading of VCR to reduce plugin overhead. `#145`_
+- Documentation improvements.
+
 `0.13.1`_ - 2023-12-07
 ----------------------
 
@@ -198,7 +204,8 @@ Added
 
 - Initial public release
 
-.. _Unreleased: https://github.com/kiwicom/pytest-recording/compare/v0.13.1...HEAD
+.. _Unreleased: https://github.com/kiwicom/pytest-recording/compare/v0.13.2...HEAD
+.. _0.13.2: https://github.com/kiwicom/pytest-recording/compare/v0.13.1...v0.13.2
 .. _0.13.1: https://github.com/kiwicom/pytest-recording/compare/v0.13.0...v0.13.1
 .. _0.13.0: https://github.com/kiwicom/pytest-recording/compare/v0.12.2...v0.13.0
 .. _0.12.2: https://github.com/kiwicom/pytest-recording/compare/v0.12.1...v0.12.2
@@ -222,6 +229,7 @@ Added
 .. _0.3.0: https://github.com/kiwicom/pytest-recording/compare/v0.2.0...v0.3.0
 .. _0.2.0: https://github.com/kiwicom/pytest-recording/compare/v0.1.0...v0.2.0
 
+.. _#145: https://github.com/kiwicom/pytest-recording/issues/145
 .. _#118: https://github.com/kiwicom/pytest-recording/pull/118
 .. _#99: https://github.com/kiwicom/pytest-recording/pull/99
 .. _#97: https://github.com/kiwicom/pytest-recording/issues/97


=====================================
pyproject.toml
=====================================
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
 
 [project]
 name = "pytest-recording"
-version = "0.13.1"
+version = "0.13.2"
 description = "A pytest plugin that allows you recording of network interactions via VCR.py"
 keywords = ["pytest", "vcr", "network", "mock"]
 authors = [{ name = "Dmitry Dygalo", email = "dmitry at dygalo.dev" }]
@@ -42,7 +42,7 @@ tests = [
     "pytest-httpbin",
     "pytest-mock",
     "requests",
-    "Werkzeug==3.0.1"
+    "Werkzeug==3.0.3"
 ]
 dev = ["pytest_recording[tests]"]
 
@@ -51,7 +51,6 @@ Documentation = "https://github.com/kiwicom/pytest-recording"
 Changelog = "https://github.com/kiwicom/pytest-recording/blob/master/docs/changelog.rst"
 "Bug Tracker" = "https://github.com/kiwicom/pytest-recording/issues"
 "Source Code" = "https://github.com/kiwicom/pytest-recording"
-"Change Log" = "https://github.com/kiwicom/pytest-recording/blob/master/docs/changelog.rst"
 
 [project.entry-points.pytest11]
 recording = "pytest_recording.plugin"


=====================================
src/pytest_recording/_vcr.py
=====================================
@@ -1,9 +1,8 @@
 import os
-from copy import deepcopy
 from dataclasses import dataclass
 from itertools import chain, starmap
 from types import ModuleType
-from typing import Any, Callable, Dict, List, Tuple
+from typing import Callable, List, Tuple
 
 from _pytest.config import Config
 from _pytest.mark.structures import Mark
@@ -19,9 +18,7 @@ except ImportError:
     # VCR.py <5
     CassetteNotFoundError = ValueError
 
-from .utils import unique, unpack
-
-ConfigType = Dict[str, Any]
+from .utils import ConfigType, merge_kwargs, unique, unpack
 
 
 def load_cassette(cassette_path: str, serializer: ModuleType) -> Tuple[List, List]:
@@ -104,11 +101,3 @@ def get_path_transformer(config: ConfigType) -> Callable:
     else:
         suffix = ".yaml"
     return VCR.ensure_suffix(suffix)
-
-
-def merge_kwargs(config: ConfigType, markers: List[Mark]) -> ConfigType:
-    """Merge all kwargs into a single dictionary to pass to `vcr.use_cassette`."""
-    kwargs = deepcopy(config)
-    for marker in reversed(markers):
-        kwargs.update(marker.kwargs)
-    return kwargs


=====================================
src/pytest_recording/hooks.py
=====================================
@@ -1,6 +1,9 @@
 from _pytest.config import Config
-from vcr import VCR
+from typing import TYPE_CHECKING
 
+if TYPE_CHECKING:
+    from vcr import VCR
 
-def pytest_recording_configure(config: Config, vcr: VCR) -> None:
+
+def pytest_recording_configure(config: Config, vcr: "VCR") -> None:
     pass  # pragma: no cover


=====================================
src/pytest_recording/plugin.py
=====================================
@@ -1,15 +1,17 @@
 import os
-from typing import Any, Dict, Iterator, List, Optional
+from typing import Any, Dict, Iterator, List, Optional, TYPE_CHECKING
 
 import pytest
 from _pytest.config import Config, PytestPluginManager
 from _pytest.config.argparsing import Parser
 from _pytest.fixtures import SubRequest
 from _pytest.mark.structures import Mark
-from vcr.cassette import Cassette
+
+if TYPE_CHECKING:
+    from vcr.cassette import Cassette
 
 from . import hooks, network
-from ._vcr import merge_kwargs, use_cassette
+from .utils import merge_kwargs
 from .validation import validate_block_network_mark
 
 RECORD_MODES = ("once", "new_episodes", "none", "all", "rewrite")
@@ -144,11 +146,13 @@ def vcr(
     record_mode: str,
     disable_recording: bool,
     pytestconfig: Config,
-) -> Iterator[Optional[Cassette]]:
+) -> Iterator[Optional["Cassette"]]:
     """Install a cassette if a test is marked with `pytest.mark.vcr`."""
     if disable_recording:
         yield None
     elif vcr_markers:
+        from ._vcr import use_cassette
+
         config = request.getfixturevalue("vcr_config")
         default_cassette = request.getfixturevalue("default_cassette_name")
         with use_cassette(


=====================================
src/pytest_recording/utils.py
=====================================
@@ -1,5 +1,9 @@
+from copy import deepcopy
 from itertools import chain
-from typing import Any, Iterable, Iterator
+from typing import Any, Dict, Iterable, Iterator, List
+from _pytest.mark.structures import Mark
+
+ConfigType = Dict[str, Any]
 
 
 def unique(sequence: Iterable) -> Iterator:
@@ -12,3 +16,11 @@ def unique(sequence: Iterable) -> Iterator:
 
 def unpack(*args: Any) -> Iterable:
     return chain.from_iterable(args)
+
+
+def merge_kwargs(config: ConfigType, markers: List[Mark]) -> ConfigType:
+    """Merge all kwargs into a single dictionary to pass to `vcr.use_cassette`."""
+    kwargs = deepcopy(config)
+    for marker in reversed(markers):
+        kwargs.update(marker.kwargs)
+    return kwargs



View it on GitLab: https://salsa.debian.org/debian-gis-team/pytest-recording/-/compare/8900c7c78b12be68f196058dcf61c8b7c3eb4d01...9b593f701e2e9fa1e2da2161a4051157484a7063

-- 
This project does not include diff previews in email notifications.
View it on GitLab: https://salsa.debian.org/debian-gis-team/pytest-recording/-/compare/8900c7c78b12be68f196058dcf61c8b7c3eb4d01...9b593f701e2e9fa1e2da2161a4051157484a7063
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-grass-devel/attachments/20240713/3679dc70/attachment-0001.htm>


More information about the Pkg-grass-devel mailing list