forked from pool/python-responses
- Add py_old_re_Pattern.patch to make package buildable even on SLE-15-SP3. OBS-URL: https://build.opensuse.org/request/show/993540 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-responses?expand=0&rev=45
71 lines
2.1 KiB
Diff
71 lines
2.1 KiB
Diff
---
|
|
responses/__init__.py | 23 ++++++++++++-----------
|
|
responses/tests/test_responses.py | 3 +++
|
|
2 files changed, 15 insertions(+), 11 deletions(-)
|
|
|
|
--- a/responses/__init__.py
|
|
+++ b/responses/__init__.py
|
|
@@ -7,7 +7,6 @@ from collections.abc import Sized
|
|
from functools import wraps
|
|
from http import client
|
|
from itertools import groupby
|
|
-from re import Pattern
|
|
from threading import Lock as _ThreadingLock
|
|
from typing import TYPE_CHECKING
|
|
from typing import Any
|
|
@@ -34,9 +33,11 @@ from responses.matchers import urlencode
|
|
from responses.registries import FirstMatchRegistry
|
|
|
|
try:
|
|
- from typing_extensions import Literal
|
|
-except ImportError: # pragma: no cover
|
|
- from typing import Literal # type: ignore # pragma: no cover
|
|
+ from re import Pattern
|
|
+except ImportError:
|
|
+ from re import compile
|
|
+ Pattern = type(compile(''))
|
|
+ del compile
|
|
|
|
try:
|
|
from requests.packages.urllib3.response import HTTPResponse
|
|
@@ -623,13 +624,13 @@ class OriginalResponseShim(object):
|
|
|
|
|
|
class RequestsMock(object):
|
|
- DELETE: Literal["DELETE"] = "DELETE"
|
|
- GET: Literal["GET"] = "GET"
|
|
- HEAD: Literal["HEAD"] = "HEAD"
|
|
- OPTIONS: Literal["OPTIONS"] = "OPTIONS"
|
|
- PATCH: Literal["PATCH"] = "PATCH"
|
|
- POST: Literal["POST"] = "POST"
|
|
- PUT: Literal["PUT"] = "PUT"
|
|
+ DELETE: Any = "DELETE"
|
|
+ GET: Any = "GET"
|
|
+ HEAD: Any = "HEAD"
|
|
+ OPTIONS: Any = "OPTIONS"
|
|
+ PATCH: Any = "PATCH"
|
|
+ POST: Any = "POST"
|
|
+ PUT: Any = "PUT"
|
|
|
|
response_callback: Optional[Callable[[Any], Any]] = None
|
|
|
|
--- a/responses/tests/test_responses.py
|
|
+++ b/responses/tests/test_responses.py
|
|
@@ -3,6 +3,7 @@
|
|
import inspect
|
|
import os
|
|
import re
|
|
+import sys
|
|
import warnings
|
|
from io import BufferedReader
|
|
from io import BytesIO
|
|
@@ -562,6 +563,8 @@ def test_callback():
|
|
assert_reset()
|
|
|
|
|
|
+@pytest.mark.skipif(sys.version_info[:2] <= (3, 6),
|
|
+ reason="test doesn't work on Python 3.6")
|
|
def test_deprecated_package_attributes():
|
|
"""Validates that deprecation warning is raised when package attributes are called."""
|
|
# keep separate context manager to avoid leakage
|