CacheControl 0.12.12__tar.gz → 0.12.14__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. {CacheControl-0.12.12 → CacheControl-0.12.14}/CacheControl.egg-info/PKG-INFO +1 -5
  2. CacheControl-0.12.14/CacheControl.egg-info/SOURCES.txt +89 -0
  3. {CacheControl-0.12.12 → CacheControl-0.12.14}/CacheControl.egg-info/entry_points.txt +0 -1
  4. {CacheControl-0.12.12 → CacheControl-0.12.14}/CacheControl.egg-info/requires.txt +1 -1
  5. {CacheControl-0.12.12 → CacheControl-0.12.14}/CacheControl.egg-info/top_level.txt +0 -1
  6. CacheControl-0.12.14/MANIFEST.in +1 -0
  7. {CacheControl-0.12.12 → CacheControl-0.12.14}/PKG-INFO +1 -5
  8. {CacheControl-0.12.12 → CacheControl-0.12.14}/cachecontrol/__init__.py +1 -1
  9. {CacheControl-0.12.12 → CacheControl-0.12.14}/cachecontrol/caches/file_cache.py +17 -7
  10. {CacheControl-0.12.12 → CacheControl-0.12.14}/cachecontrol/serialize.py +4 -1
  11. {CacheControl-0.12.12 → CacheControl-0.12.14}/setup.py +3 -3
  12. CacheControl-0.12.14/tests/__pycache__/__init__.cpython-310.pyc +0 -0
  13. CacheControl-0.12.14/tests/__pycache__/__init__.cpython-311.pyc +0 -0
  14. CacheControl-0.12.14/tests/__pycache__/__init__.cpython-39.pyc +0 -0
  15. CacheControl-0.12.14/tests/__pycache__/conftest.cpython-310-pytest-7.3.1.pyc +0 -0
  16. CacheControl-0.12.14/tests/__pycache__/conftest.cpython-311-pytest-7.3.1.pyc +0 -0
  17. CacheControl-0.12.14/tests/__pycache__/conftest.cpython-39-pytest-7.3.1.pyc +0 -0
  18. CacheControl-0.12.14/tests/__pycache__/test_adapter.cpython-310-pytest-7.3.1.pyc +0 -0
  19. CacheControl-0.12.14/tests/__pycache__/test_adapter.cpython-311-pytest-7.3.1.pyc +0 -0
  20. CacheControl-0.12.14/tests/__pycache__/test_adapter.cpython-39-pytest-7.3.1.pyc +0 -0
  21. CacheControl-0.12.14/tests/__pycache__/test_cache_control.cpython-310-pytest-7.3.1.pyc +0 -0
  22. CacheControl-0.12.14/tests/__pycache__/test_cache_control.cpython-311-pytest-7.3.1.pyc +0 -0
  23. CacheControl-0.12.14/tests/__pycache__/test_cache_control.cpython-39-pytest-7.3.1.pyc +0 -0
  24. CacheControl-0.12.14/tests/__pycache__/test_chunked_response.cpython-310-pytest-7.3.1.pyc +0 -0
  25. CacheControl-0.12.14/tests/__pycache__/test_chunked_response.cpython-311-pytest-7.3.1.pyc +0 -0
  26. CacheControl-0.12.14/tests/__pycache__/test_chunked_response.cpython-39-pytest-7.3.1.pyc +0 -0
  27. CacheControl-0.12.14/tests/__pycache__/test_etag.cpython-310-pytest-7.3.1.pyc +0 -0
  28. CacheControl-0.12.14/tests/__pycache__/test_etag.cpython-311-pytest-7.3.1.pyc +0 -0
  29. CacheControl-0.12.14/tests/__pycache__/test_etag.cpython-39-pytest-7.3.1.pyc +0 -0
  30. CacheControl-0.12.14/tests/__pycache__/test_expires_heuristics.cpython-310-pytest-7.3.1.pyc +0 -0
  31. CacheControl-0.12.14/tests/__pycache__/test_expires_heuristics.cpython-311-pytest-7.3.1.pyc +0 -0
  32. CacheControl-0.12.14/tests/__pycache__/test_expires_heuristics.cpython-39-pytest-7.3.1.pyc +0 -0
  33. CacheControl-0.12.14/tests/__pycache__/test_max_age.cpython-310-pytest-7.3.1.pyc +0 -0
  34. CacheControl-0.12.14/tests/__pycache__/test_max_age.cpython-311-pytest-7.3.1.pyc +0 -0
  35. CacheControl-0.12.14/tests/__pycache__/test_max_age.cpython-39-pytest-7.3.1.pyc +0 -0
  36. CacheControl-0.12.14/tests/__pycache__/test_redirects.cpython-310-pytest-7.3.1.pyc +0 -0
  37. CacheControl-0.12.14/tests/__pycache__/test_redirects.cpython-311-pytest-7.3.1.pyc +0 -0
  38. CacheControl-0.12.14/tests/__pycache__/test_redirects.cpython-39-pytest-7.3.1.pyc +0 -0
  39. CacheControl-0.12.14/tests/__pycache__/test_regressions.cpython-310-pytest-7.3.1.pyc +0 -0
  40. CacheControl-0.12.14/tests/__pycache__/test_regressions.cpython-311-pytest-7.3.1.pyc +0 -0
  41. CacheControl-0.12.14/tests/__pycache__/test_regressions.cpython-39-pytest-7.3.1.pyc +0 -0
  42. CacheControl-0.12.14/tests/__pycache__/test_serialization.cpython-310-pytest-7.3.1.pyc +0 -0
  43. CacheControl-0.12.14/tests/__pycache__/test_serialization.cpython-311-pytest-7.3.1.pyc +0 -0
  44. CacheControl-0.12.14/tests/__pycache__/test_serialization.cpython-39-pytest-7.3.1.pyc +0 -0
  45. CacheControl-0.12.14/tests/__pycache__/test_server_http_version.cpython-310-pytest-7.3.1.pyc +0 -0
  46. CacheControl-0.12.14/tests/__pycache__/test_server_http_version.cpython-311-pytest-7.3.1.pyc +0 -0
  47. CacheControl-0.12.14/tests/__pycache__/test_server_http_version.cpython-39-pytest-7.3.1.pyc +0 -0
  48. CacheControl-0.12.14/tests/__pycache__/test_storage_filecache.cpython-310-pytest-7.3.1.pyc +0 -0
  49. CacheControl-0.12.14/tests/__pycache__/test_storage_filecache.cpython-311-pytest-7.3.1.pyc +0 -0
  50. CacheControl-0.12.14/tests/__pycache__/test_storage_filecache.cpython-39-pytest-7.3.1.pyc +0 -0
  51. CacheControl-0.12.14/tests/__pycache__/test_storage_redis.cpython-310-pytest-7.3.1.pyc +0 -0
  52. CacheControl-0.12.14/tests/__pycache__/test_storage_redis.cpython-311-pytest-7.3.1.pyc +0 -0
  53. CacheControl-0.12.14/tests/__pycache__/test_storage_redis.cpython-39-pytest-7.3.1.pyc +0 -0
  54. CacheControl-0.12.14/tests/__pycache__/test_vary.cpython-310-pytest-7.3.1.pyc +0 -0
  55. CacheControl-0.12.14/tests/__pycache__/test_vary.cpython-311-pytest-7.3.1.pyc +0 -0
  56. CacheControl-0.12.14/tests/__pycache__/test_vary.cpython-39-pytest-7.3.1.pyc +0 -0
  57. CacheControl-0.12.14/tests/__pycache__/utils.cpython-310.pyc +0 -0
  58. CacheControl-0.12.14/tests/__pycache__/utils.cpython-311.pyc +0 -0
  59. CacheControl-0.12.14/tests/__pycache__/utils.cpython-39.pyc +0 -0
  60. {CacheControl-0.12.12 → CacheControl-0.12.14}/tests/conftest.py +10 -0
  61. {CacheControl-0.12.12 → CacheControl-0.12.14}/tests/test_etag.py +15 -4
  62. {CacheControl-0.12.12 → CacheControl-0.12.14}/tests/test_serialization.py +6 -0
  63. {CacheControl-0.12.12 → CacheControl-0.12.14}/tests/test_storage_filecache.py +18 -6
  64. {CacheControl-0.12.12 → CacheControl-0.12.14}/tests/test_vary.py +0 -1
  65. CacheControl-0.12.12/CacheControl.egg-info/SOURCES.txt +0 -40
  66. {CacheControl-0.12.12 → CacheControl-0.12.14}/CacheControl.egg-info/dependency_links.txt +0 -0
  67. {CacheControl-0.12.12 → CacheControl-0.12.14}/LICENSE.txt +0 -0
  68. {CacheControl-0.12.12 → CacheControl-0.12.14}/README.rst +0 -0
  69. {CacheControl-0.12.12 → CacheControl-0.12.14}/cachecontrol/_cmd.py +0 -0
  70. {CacheControl-0.12.12 → CacheControl-0.12.14}/cachecontrol/adapter.py +0 -0
  71. {CacheControl-0.12.12 → CacheControl-0.12.14}/cachecontrol/cache.py +0 -0
  72. {CacheControl-0.12.12 → CacheControl-0.12.14}/cachecontrol/caches/__init__.py +0 -0
  73. {CacheControl-0.12.12 → CacheControl-0.12.14}/cachecontrol/caches/redis_cache.py +0 -0
  74. {CacheControl-0.12.12 → CacheControl-0.12.14}/cachecontrol/compat.py +0 -0
  75. {CacheControl-0.12.12 → CacheControl-0.12.14}/cachecontrol/controller.py +0 -0
  76. {CacheControl-0.12.12 → CacheControl-0.12.14}/cachecontrol/filewrapper.py +0 -0
  77. {CacheControl-0.12.12 → CacheControl-0.12.14}/cachecontrol/heuristics.py +0 -0
  78. {CacheControl-0.12.12 → CacheControl-0.12.14}/cachecontrol/wrapper.py +0 -0
  79. {CacheControl-0.12.12 → CacheControl-0.12.14}/setup.cfg +0 -0
  80. {CacheControl-0.12.12 → CacheControl-0.12.14}/tests/__init__.py +0 -0
  81. {CacheControl-0.12.12 → CacheControl-0.12.14}/tests/issue_263.py +0 -0
  82. {CacheControl-0.12.12 → CacheControl-0.12.14}/tests/test_adapter.py +0 -0
  83. {CacheControl-0.12.12 → CacheControl-0.12.14}/tests/test_cache_control.py +0 -0
  84. {CacheControl-0.12.12 → CacheControl-0.12.14}/tests/test_chunked_response.py +0 -0
  85. {CacheControl-0.12.12 → CacheControl-0.12.14}/tests/test_expires_heuristics.py +0 -0
  86. {CacheControl-0.12.12 → CacheControl-0.12.14}/tests/test_max_age.py +0 -0
  87. {CacheControl-0.12.12 → CacheControl-0.12.14}/tests/test_redirects.py +0 -0
  88. {CacheControl-0.12.12 → CacheControl-0.12.14}/tests/test_regressions.py +0 -0
  89. {CacheControl-0.12.12 → CacheControl-0.12.14}/tests/test_server_http_version.py +0 -0
  90. {CacheControl-0.12.12 → CacheControl-0.12.14}/tests/test_storage_redis.py +0 -0
  91. {CacheControl-0.12.12 → CacheControl-0.12.14}/tests/utils.py +0 -0
@@ -1,13 +1,11 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: CacheControl
3
- Version: 0.12.12
3
+ Version: 0.12.14
4
4
  Summary: httplib2 caching for requests
5
5
  Home-page: https://github.com/ionrock/cachecontrol
6
6
  Author: Eric Larson
7
7
  Author-email: eric@ionrock.org
8
- License: UNKNOWN
9
8
  Keywords: requests http caching web
10
- Platform: UNKNOWN
11
9
  Classifier: Development Status :: 4 - Beta
12
10
  Classifier: Environment :: Web Environment
13
11
  Classifier: License :: OSI Approved :: Apache Software License
@@ -70,5 +68,3 @@ For more info, check out the docs_
70
68
  .. _docs: http://cachecontrol.readthedocs.org/en/latest/
71
69
  .. _httplib2: https://github.com/httplib2/httplib2
72
70
  .. _requests: http://docs.python-requests.org/
73
-
74
-
@@ -0,0 +1,89 @@
1
+ LICENSE.txt
2
+ MANIFEST.in
3
+ README.rst
4
+ setup.cfg
5
+ setup.py
6
+ CacheControl.egg-info/PKG-INFO
7
+ CacheControl.egg-info/SOURCES.txt
8
+ CacheControl.egg-info/dependency_links.txt
9
+ CacheControl.egg-info/entry_points.txt
10
+ CacheControl.egg-info/requires.txt
11
+ CacheControl.egg-info/top_level.txt
12
+ cachecontrol/__init__.py
13
+ cachecontrol/_cmd.py
14
+ cachecontrol/adapter.py
15
+ cachecontrol/cache.py
16
+ cachecontrol/compat.py
17
+ cachecontrol/controller.py
18
+ cachecontrol/filewrapper.py
19
+ cachecontrol/heuristics.py
20
+ cachecontrol/serialize.py
21
+ cachecontrol/wrapper.py
22
+ cachecontrol/caches/__init__.py
23
+ cachecontrol/caches/file_cache.py
24
+ cachecontrol/caches/redis_cache.py
25
+ tests/__init__.py
26
+ tests/conftest.py
27
+ tests/issue_263.py
28
+ tests/test_adapter.py
29
+ tests/test_cache_control.py
30
+ tests/test_chunked_response.py
31
+ tests/test_etag.py
32
+ tests/test_expires_heuristics.py
33
+ tests/test_max_age.py
34
+ tests/test_redirects.py
35
+ tests/test_regressions.py
36
+ tests/test_serialization.py
37
+ tests/test_server_http_version.py
38
+ tests/test_storage_filecache.py
39
+ tests/test_storage_redis.py
40
+ tests/test_vary.py
41
+ tests/utils.py
42
+ tests/__pycache__/__init__.cpython-310.pyc
43
+ tests/__pycache__/__init__.cpython-311.pyc
44
+ tests/__pycache__/__init__.cpython-39.pyc
45
+ tests/__pycache__/conftest.cpython-310-pytest-7.3.1.pyc
46
+ tests/__pycache__/conftest.cpython-311-pytest-7.3.1.pyc
47
+ tests/__pycache__/conftest.cpython-39-pytest-7.3.1.pyc
48
+ tests/__pycache__/test_adapter.cpython-310-pytest-7.3.1.pyc
49
+ tests/__pycache__/test_adapter.cpython-311-pytest-7.3.1.pyc
50
+ tests/__pycache__/test_adapter.cpython-39-pytest-7.3.1.pyc
51
+ tests/__pycache__/test_cache_control.cpython-310-pytest-7.3.1.pyc
52
+ tests/__pycache__/test_cache_control.cpython-311-pytest-7.3.1.pyc
53
+ tests/__pycache__/test_cache_control.cpython-39-pytest-7.3.1.pyc
54
+ tests/__pycache__/test_chunked_response.cpython-310-pytest-7.3.1.pyc
55
+ tests/__pycache__/test_chunked_response.cpython-311-pytest-7.3.1.pyc
56
+ tests/__pycache__/test_chunked_response.cpython-39-pytest-7.3.1.pyc
57
+ tests/__pycache__/test_etag.cpython-310-pytest-7.3.1.pyc
58
+ tests/__pycache__/test_etag.cpython-311-pytest-7.3.1.pyc
59
+ tests/__pycache__/test_etag.cpython-39-pytest-7.3.1.pyc
60
+ tests/__pycache__/test_expires_heuristics.cpython-310-pytest-7.3.1.pyc
61
+ tests/__pycache__/test_expires_heuristics.cpython-311-pytest-7.3.1.pyc
62
+ tests/__pycache__/test_expires_heuristics.cpython-39-pytest-7.3.1.pyc
63
+ tests/__pycache__/test_max_age.cpython-310-pytest-7.3.1.pyc
64
+ tests/__pycache__/test_max_age.cpython-311-pytest-7.3.1.pyc
65
+ tests/__pycache__/test_max_age.cpython-39-pytest-7.3.1.pyc
66
+ tests/__pycache__/test_redirects.cpython-310-pytest-7.3.1.pyc
67
+ tests/__pycache__/test_redirects.cpython-311-pytest-7.3.1.pyc
68
+ tests/__pycache__/test_redirects.cpython-39-pytest-7.3.1.pyc
69
+ tests/__pycache__/test_regressions.cpython-310-pytest-7.3.1.pyc
70
+ tests/__pycache__/test_regressions.cpython-311-pytest-7.3.1.pyc
71
+ tests/__pycache__/test_regressions.cpython-39-pytest-7.3.1.pyc
72
+ tests/__pycache__/test_serialization.cpython-310-pytest-7.3.1.pyc
73
+ tests/__pycache__/test_serialization.cpython-311-pytest-7.3.1.pyc
74
+ tests/__pycache__/test_serialization.cpython-39-pytest-7.3.1.pyc
75
+ tests/__pycache__/test_server_http_version.cpython-310-pytest-7.3.1.pyc
76
+ tests/__pycache__/test_server_http_version.cpython-311-pytest-7.3.1.pyc
77
+ tests/__pycache__/test_server_http_version.cpython-39-pytest-7.3.1.pyc
78
+ tests/__pycache__/test_storage_filecache.cpython-310-pytest-7.3.1.pyc
79
+ tests/__pycache__/test_storage_filecache.cpython-311-pytest-7.3.1.pyc
80
+ tests/__pycache__/test_storage_filecache.cpython-39-pytest-7.3.1.pyc
81
+ tests/__pycache__/test_storage_redis.cpython-310-pytest-7.3.1.pyc
82
+ tests/__pycache__/test_storage_redis.cpython-311-pytest-7.3.1.pyc
83
+ tests/__pycache__/test_storage_redis.cpython-39-pytest-7.3.1.pyc
84
+ tests/__pycache__/test_vary.cpython-310-pytest-7.3.1.pyc
85
+ tests/__pycache__/test_vary.cpython-311-pytest-7.3.1.pyc
86
+ tests/__pycache__/test_vary.cpython-39-pytest-7.3.1.pyc
87
+ tests/__pycache__/utils.cpython-310.pyc
88
+ tests/__pycache__/utils.cpython-311.pyc
89
+ tests/__pycache__/utils.cpython-39.pyc
@@ -1,3 +1,2 @@
1
1
  [console_scripts]
2
2
  doesitcache = cachecontrol._cmd:main
3
-
@@ -2,7 +2,7 @@ requests
2
2
  msgpack>=0.5.2
3
3
 
4
4
  [filecache]
5
- filelock>=3.8.0
5
+ lockfile>=0.9
6
6
 
7
7
  [redis]
8
8
  redis>=2.10.5
@@ -0,0 +1 @@
1
+ graft tests/
@@ -1,13 +1,11 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: CacheControl
3
- Version: 0.12.12
3
+ Version: 0.12.14
4
4
  Summary: httplib2 caching for requests
5
5
  Home-page: https://github.com/ionrock/cachecontrol
6
6
  Author: Eric Larson
7
7
  Author-email: eric@ionrock.org
8
- License: UNKNOWN
9
8
  Keywords: requests http caching web
10
- Platform: UNKNOWN
11
9
  Classifier: Development Status :: 4 - Beta
12
10
  Classifier: Environment :: Web Environment
13
11
  Classifier: License :: OSI Approved :: Apache Software License
@@ -70,5 +68,3 @@ For more info, check out the docs_
70
68
  .. _docs: http://cachecontrol.readthedocs.org/en/latest/
71
69
  .. _httplib2: https://github.com/httplib2/httplib2
72
70
  .. _requests: http://docs.python-requests.org/
73
-
74
-
@@ -8,7 +8,7 @@ Make it easy to import from cachecontrol without long namespaces.
8
8
  """
9
9
  __author__ = "Eric Larson"
10
10
  __email__ = "eric@ionrock.org"
11
- __version__ = "0.12.12"
11
+ __version__ = "0.12.14"
12
12
 
13
13
  from .wrapper import CacheControl
14
14
  from .adapter import CacheControlAdapter
@@ -66,23 +66,33 @@ class _FileCacheMixin:
66
66
  forever=False,
67
67
  filemode=0o0600,
68
68
  dirmode=0o0700,
69
+ use_dir_lock=None,
69
70
  lock_class=None,
70
71
  ):
71
72
 
73
+ if use_dir_lock is not None and lock_class is not None:
74
+ raise ValueError("Cannot use use_dir_lock and lock_class together")
75
+
72
76
  try:
73
- if lock_class is None:
74
- from filelock import FileLock
75
- lock_class = FileLock
77
+ from lockfile import LockFile
78
+ from lockfile.mkdirlockfile import MkdirLockFile
76
79
  except ImportError:
77
80
  notice = dedent(
78
81
  """
79
82
  NOTE: In order to use the FileCache you must have
80
- filelock installed. You can install it via pip:
81
- pip install filelock
83
+ lockfile installed. You can install it via pip:
84
+ pip install lockfile
82
85
  """
83
86
  )
84
87
  raise ImportError(notice)
85
88
 
89
+ else:
90
+ if use_dir_lock:
91
+ lock_class = MkdirLockFile
92
+
93
+ elif lock_class is None:
94
+ lock_class = LockFile
95
+
86
96
  self.directory = directory
87
97
  self.forever = forever
88
98
  self.filemode = filemode
@@ -123,9 +133,9 @@ class _FileCacheMixin:
123
133
  except (IOError, OSError):
124
134
  pass
125
135
 
126
- with self.lock_class(path + ".lock"):
136
+ with self.lock_class(path) as lock:
127
137
  # Write our actual file
128
- with _secure_open_write(path, self.filemode) as fh:
138
+ with _secure_open_write(lock.path, self.filemode) as fh:
129
139
  fh.write(data)
130
140
 
131
141
  def _delete(self, key, suffix):
@@ -34,6 +34,7 @@ class Serializer(object):
34
34
  # sure it acts as though it was never read.
35
35
  body = response.read(decode_content=False)
36
36
  response._fp = io.BytesIO(body)
37
+ response.length_remaining = len(body)
37
38
 
38
39
  # NOTE: This is all a bit weird, but it's really important that on
39
40
  # Python 2.x these objects are unicode and not str, even when
@@ -51,7 +52,6 @@ class Serializer(object):
51
52
  u"status": response.status,
52
53
  u"version": response.version,
53
54
  u"reason": text_type(response.reason),
54
- u"strict": response.strict,
55
55
  u"decode_content": response.decode_content,
56
56
  }
57
57
  }
@@ -138,6 +138,9 @@ class Serializer(object):
138
138
  # TypeError: 'str' does not support the buffer interface
139
139
  body = io.BytesIO(body_raw.encode("utf8"))
140
140
 
141
+ # Discard any `strict` parameter serialized by older version of cachecontrol.
142
+ cached["response"].pop("strict", None)
143
+
141
144
  return HTTPResponse(body=body, preload_content=False, **cached["response"])
142
145
 
143
146
  def _loads_v0(self, request, data, body_file=None):
@@ -6,7 +6,7 @@ import setuptools
6
6
 
7
7
  long_description = open("README.rst").read()
8
8
 
9
- VERSION = "0.12.12"
9
+ VERSION = "0.12.14"
10
10
 
11
11
  setup_params = dict(
12
12
  name="CacheControl",
@@ -15,14 +15,14 @@ setup_params = dict(
15
15
  author_email="eric@ionrock.org",
16
16
  url="https://github.com/ionrock/cachecontrol",
17
17
  keywords="requests http caching web",
18
- packages=setuptools.find_packages(),
18
+ packages=setuptools.find_packages(exclude=["tests", "tests.*"]),
19
19
  package_data={"": ["LICENSE.txt"]},
20
20
  package_dir={"cachecontrol": "cachecontrol"},
21
21
  include_package_data=True,
22
22
  description="httplib2 caching for requests",
23
23
  long_description=long_description,
24
24
  install_requires=["requests", "msgpack>=0.5.2"],
25
- extras_require={"filecache": ["filelock>=3.8.0"], "redis": ["redis>=2.10.5"]},
25
+ extras_require={"filecache": ["lockfile>=0.9"], "redis": ["redis>=2.10.5"]},
26
26
  entry_points={"console_scripts": ["doesitcache = cachecontrol._cmd:main"]},
27
27
  python_requires=">=3.6",
28
28
  classifiers=[
@@ -104,6 +104,16 @@ class SimpleApp(object):
104
104
  for i in range(10):
105
105
  yield pformat(i).encode("utf8")
106
106
 
107
+ def fixed_length(self, env, start_response):
108
+ body = b"0123456789"
109
+ headers = [
110
+ ("Content-Type", "text/plain"),
111
+ ("Cache-Control", "max-age=5000"),
112
+ ("Content-Length", str(len(body)))
113
+ ]
114
+ start_response("200 OK", headers)
115
+ return [body]
116
+
107
117
  def __call__(self, env, start_response):
108
118
  func = self.dispatch(env)
109
119
 
@@ -1,6 +1,8 @@
1
1
  # SPDX-FileCopyrightText: 2015 Eric Larson
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
+ from contextlib import ExitStack
5
+ from contextlib import suppress
4
6
 
5
7
  import pytest
6
8
 
@@ -134,11 +136,20 @@ class TestReleaseConnection(object):
134
136
 
135
137
  resp = Mock(status=304, headers={})
136
138
 
137
- # This is how the urllib3 response is created in
138
- # requests.adapters
139
- response_mod = "requests.adapters.HTTPResponse.from_httplib"
139
+ # These are various ways the the urllib3 response can created
140
+ # in requests.adapters. Which one is actually used depends
141
+ # on which version if `requests` is in use, as well as perhaps
142
+ # other parameters.
143
+ response_mods = [
144
+ "requests.adapters.HTTPResponse.from_httplib",
145
+ "urllib3.HTTPConnectionPool.urlopen",
146
+ ]
147
+
148
+ with ExitStack() as stack:
149
+ for mod in response_mods:
150
+ with suppress(ImportError):
151
+ stack.enter_context(patch(mod, Mock(return_value=resp)))
140
152
 
141
- with patch(response_mod, Mock(return_value=resp)):
142
153
  sess.get(etag_url)
143
154
  assert resp.read.called
144
155
  assert resp.release_conn.called
@@ -135,3 +135,9 @@ class TestSerializer(object):
135
135
  # handle. Reading it again proves we're resetting the internal
136
136
  # file handle with a buffer.
137
137
  assert original_resp.raw.read()
138
+
139
+ def test_no_incomplete_read_on_dumps(self, url):
140
+ resp = requests.get(url + "fixed_length", stream=True)
141
+ self.serializer.dumps(resp.request, resp.raw)
142
+
143
+ assert resp.content == b"0123456789"
@@ -14,7 +14,8 @@ import pytest
14
14
  import requests
15
15
  from cachecontrol import CacheControl
16
16
  from cachecontrol.caches import FileCache, SeparateBodyFileCache
17
- from filelock import FileLock
17
+ from lockfile import LockFile
18
+ from lockfile.mkdirlockfile import MkdirLockFile
18
19
 
19
20
 
20
21
  def randomdata():
@@ -93,10 +94,21 @@ class FileCacheTestsMixin(object):
93
94
  assert len(self.cache.encode(url0)) < 200
94
95
  assert len(self.cache.encode(url0)) == len(self.cache.encode(url1))
95
96
 
96
- def test_simple_lockfile_arg(self, tmpdir):
97
- cache = self.FileCacheClass(str(tmpdir))
98
-
99
- assert issubclass(cache.lock_class, FileLock)
97
+ def test_cant_use_dir_and_lock_class(self, tmpdir):
98
+ with pytest.raises(ValueError):
99
+ self.FileCacheClass(str(tmpdir), use_dir_lock=True, lock_class=object())
100
+
101
+ @pytest.mark.parametrize(
102
+ ("value", "expected"),
103
+ [(None, LockFile), (True, MkdirLockFile), (False, LockFile)],
104
+ )
105
+ def test_simple_lockfile_arg(self, tmpdir, value, expected):
106
+ if value is not None:
107
+ cache = self.FileCacheClass(str(tmpdir), use_dir_lock=value)
108
+ else:
109
+ cache = self.FileCacheClass(str(tmpdir))
110
+
111
+ assert issubclass(cache.lock_class, expected)
100
112
  cache.close()
101
113
 
102
114
  def test_lock_class(self, tmpdir):
@@ -122,7 +134,7 @@ class TestFileCache(FileCacheTestsMixin):
122
134
  """
123
135
  Tests for ``FileCache``.
124
136
  """
125
-
137
+
126
138
  FileCacheClass = FileCache
127
139
 
128
140
  def test_body_stored_inline(self, sess):
@@ -33,7 +33,6 @@ class TestVary(object):
33
33
  cached.status == resp.raw.status,
34
34
  cached.version == resp.raw.version,
35
35
  cached.reason == resp.raw.reason,
36
- cached.strict == resp.raw.strict,
37
36
  cached.decode_content == resp.raw.decode_content,
38
37
  ]
39
38
 
@@ -1,40 +0,0 @@
1
- LICENSE.txt
2
- README.rst
3
- setup.cfg
4
- setup.py
5
- CacheControl.egg-info/PKG-INFO
6
- CacheControl.egg-info/SOURCES.txt
7
- CacheControl.egg-info/dependency_links.txt
8
- CacheControl.egg-info/entry_points.txt
9
- CacheControl.egg-info/requires.txt
10
- CacheControl.egg-info/top_level.txt
11
- cachecontrol/__init__.py
12
- cachecontrol/_cmd.py
13
- cachecontrol/adapter.py
14
- cachecontrol/cache.py
15
- cachecontrol/compat.py
16
- cachecontrol/controller.py
17
- cachecontrol/filewrapper.py
18
- cachecontrol/heuristics.py
19
- cachecontrol/serialize.py
20
- cachecontrol/wrapper.py
21
- cachecontrol/caches/__init__.py
22
- cachecontrol/caches/file_cache.py
23
- cachecontrol/caches/redis_cache.py
24
- tests/__init__.py
25
- tests/conftest.py
26
- tests/issue_263.py
27
- tests/test_adapter.py
28
- tests/test_cache_control.py
29
- tests/test_chunked_response.py
30
- tests/test_etag.py
31
- tests/test_expires_heuristics.py
32
- tests/test_max_age.py
33
- tests/test_redirects.py
34
- tests/test_regressions.py
35
- tests/test_serialization.py
36
- tests/test_server_http_version.py
37
- tests/test_storage_filecache.py
38
- tests/test_storage_redis.py
39
- tests/test_vary.py
40
- tests/utils.py
File without changes