Repository: getsentry/responses
Pull request #517 (2022-03-17 16:54:10)

mbeliaev/docs depr
here is look and feel
![image](https://user-images.githubusercontent.com/51964909/158852719-de48cc55-6484-41e8-9c07-3c8b9d3c55c0.png)


@markstory 
do you think we need to add info about removed internals as well?


codecov[bot]: # [Codecov](https://app.codecov.io/gh/getsentry/responses/compare/517?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getsentry) Report
> Merging [#517](https://app.codecov.io/gh/getsentry/responses/compare/517?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getsentry) (4ca2ce6) into [master](https://codecov.io/gh/getsentry/responses/commit/1724937f354bb1ebe5d4dc4d6b976a175396b0ac?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getsentry) (1724937) will **not change** coverage.
> The diff coverage is `n/a`.

```diff
@@            Coverage Diff            @@
##            master      #517   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            6         6           
  Lines         2305      2305           
=========================================
  Hits          2305      2305           
```



------

[Continue to review full report at Codecov](https://app.codecov.io/gh/getsentry/responses/compare/517?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getsentry).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getsentry)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://app.codecov.io/gh/getsentry/responses/compare/517?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getsentry). Last update [1724937...4ca2ce6](https://app.codecov.io/gh/getsentry/responses/compare/517?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getsentry). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getsentry).


Patch:
diff --git a/CHANGES b/CHANGES
index 6e1bcf1..cd8cc23 100644
--- a/CHANGES
+++ b/CHANGES
@@ -5,6 +5,7 @@
   since they are not actual properties of the class instance.
   Use `responses.mock.assert_all_requests_are_fired`,
   `responses.mock.passthru_prefixes`, `responses.mock.target` instead.
+* Fixed the issue when `reset()` method was called in not stopped mock. See #511
 
 0.19.0
 ------
diff --git a/README.rst b/README.rst
index 5d23906..829c0a4 100644
--- a/README.rst
+++ b/README.rst
@@ -32,6 +32,38 @@ Installing
 ``pip install responses``
 
 
+Deprecations and Migration Path
+-------------------------------
+
+Here you will find a list of deprecated functionality and a migration path for each.
+Please ensure to update your code according to the guidance.
+
+.. list-table:: Deprecation and Migration
+   :widths: 50 25 50
+   :header-rows: 1
+
+   * - Deprecated Functionality
+     - Deprecated in Version
+     - Migration Path
+   * - ``responses.json_params_matcher``
+     - 0.14.0
+     - ``responses.matchers.json_params_matcher``
+   * - ``responses.urlencoded_params_matcher``
+     - 0.14.0
+     - ``responses.matchers.urlencoded_params_matcher``
+   * - ``stream`` argument in ``Response`` and ``CallbackResponse``
+     - 0.15.0
+     - Use ``stream`` argument in request directly.
+   * - ``match_querystring`` argument in ``Response`` and ``CallbackResponse``.
+     - 0.17.0
+     - Use ``responses.matchers.query_param_matcher`` or ``responses.matchers.query_string_matcher``
+   * - ``responses.assert_all_requests_are_fired``, ``responses.passthru_prefixes``, ``responses.target``
+     - 0.20.0
+     - Use ``responses.mock.assert_all_requests_are_fired``,
+       ``responses.mock.passthru_prefixes``, ``responses.mock.target`` instead.
+
+
+
 Basics
 ------
 
diff --git a/responses/__init__.py b/responses/__init__.py
index 91ee3ea..d8d5438 100644
--- a/responses/__init__.py
+++ b/responses/__init__.py
@@ -560,7 +560,6 @@ class RequestsMock(object):
         self._registry = FirstMatchRegistry()
         self._calls.reset()
         self.passthru_prefixes = ()
-        self._patcher = None
 
     def add(
         self,
@@ -834,6 +833,8 @@ class RequestsMock(object):
     def start(self):
         if self._patcher:
             # we must not override value of the _patcher if already applied
+            # this prevents issues when one decorated function is called from
+            # another decorated function
             return
 
         def unbound_on_send(adapter, request, *a, **kwargs):
@@ -847,6 +848,10 @@ class RequestsMock(object):
             # prevent stopping unstarted patchers
             self._patcher.stop()
 
+            # once patcher is stopped, clean it. This is required to create a new
+            # fresh patcher on self.start()
+            self._patcher = None
+
         if not self.assert_all_requests_are_fired:
             return
 


Test patch:
diff --git a/responses/tests/test_responses.py b/responses/tests/test_responses.py
index 9f2212c..05e816e 100644
--- a/responses/tests/test_responses.py
+++ b/responses/tests/test_responses.py
@@ -2127,3 +2127,16 @@ class TestShortcuts:
 
         run()
         assert_reset()
+
+
+def test_reset_in_the_middle():
+    @responses.activate
+    def run():
+        with responses.RequestsMock() as rsps2:
+            rsps2.reset()
+        responses.add(responses.GET, "https://example.invalid", status=200)
+        resp = requests.request("GET", "https://example.invalid")
+        assert resp.status_code == 200
+
+    run()
+    assert_reset()