Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3d25be4

Browse files
authored
Merge branch 'main' into python3.13-support
2 parents 0545d16 + 73d04c4 commit 3d25be4

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

tests/transports/test_base.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -164,43 +164,43 @@ def test_api_request_time_dynamic(mock_send, caplog, elasticapm_client):
164164
assert mock_send.call_count == 0
165165

166166

167-
@pytest.mark.skipif(sys.version_info >= (3, 12), reason="Failing locally on 3.12.0rc1") # TODO py3.12
167+
def _cleanup_flush_mock_buffers(mock_flush):
168+
args, kwargs = mock_flush.call_args
169+
buffer = args[0]
170+
buffer.close()
171+
172+
168173
@mock.patch("elasticapm.transport.base.Transport._flush")
169174
def test_api_request_size_dynamic(mock_flush, caplog, elasticapm_client):
170-
elasticapm_client.config.update(version="1", api_request_size="100b")
175+
elasticapm_client.config.update(version="1", api_request_size="9b")
171176
transport = Transport(client=elasticapm_client, queue_chill_count=1)
172177
transport.start_thread()
173178
try:
174179
with caplog.at_level("DEBUG", "elasticapm.transport"):
175-
# we need to add lots of uncompressible data to fill up the gzip-internal buffer
176-
for i in range(12):
177-
transport.queue("error", "".join(random.choice(string.ascii_letters) for i in range(2000)))
180+
transport.queue("error", "".join(random.choice(string.ascii_letters) for i in range(2000)))
178181
transport._flushed.wait(timeout=0.1)
182+
_cleanup_flush_mock_buffers(mock_flush)
179183
assert mock_flush.call_count == 1
180184
elasticapm_client.config.update(version="1", api_request_size="1mb")
181185
with caplog.at_level("DEBUG", "elasticapm.transport"):
182-
# we need to add lots of uncompressible data to fill up the gzip-internal buffer
183-
for i in range(12):
184-
transport.queue("error", "".join(random.choice(string.ascii_letters) for i in range(2000)))
186+
transport.queue("error", "".join(random.choice(string.ascii_letters) for i in range(2000)))
185187
transport._flushed.wait(timeout=0.1)
186188
# Should be unchanged because our buffer limit is much higher.
187189
assert mock_flush.call_count == 1
188190
finally:
189191
transport.close()
190192

191193

192-
@pytest.mark.skipif(sys.version_info >= (3, 12), reason="Failing locally on 3.12.0rc1") # TODO py3.12
193194
@mock.patch("elasticapm.transport.base.Transport._flush")
194-
@pytest.mark.parametrize("elasticapm_client", [{"api_request_size": "100b"}], indirect=True)
195+
@pytest.mark.parametrize("elasticapm_client", [{"api_request_size": "9b"}], indirect=True)
195196
def test_flush_time_size(mock_flush, caplog, elasticapm_client):
196197
transport = Transport(client=elasticapm_client, queue_chill_count=1)
197198
transport.start_thread()
198199
try:
199200
with caplog.at_level("DEBUG", "elasticapm.transport"):
200-
# we need to add lots of uncompressible data to fill up the gzip-internal buffer
201-
for i in range(12):
202-
transport.queue("error", "".join(random.choice(string.ascii_letters) for i in range(2000)))
201+
transport.queue("error", "".join(random.choice(string.ascii_letters) for i in range(2000)))
203202
transport._flushed.wait(timeout=0.1)
203+
_cleanup_flush_mock_buffers(mock_flush)
204204
assert mock_flush.call_count == 1
205205
finally:
206206
transport.close()

0 commit comments

Comments
 (0)