Skip to content

Commit 864a87f

Browse files
fix: flaky test
1 parent 4317ade commit 864a87f

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

auto_test.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
total_count=0
4+
error_count=0
5+
6+
for (( i = 0; i < 100; i++ )); do
7+
result=$(pytest tests/test_polars.py::TestWritePolars::test_write_polars_batching)
8+
if [[ "$result" == *"expected call not found"* ]]; then
9+
echo "$result"
10+
((error_count++))
11+
fi
12+
13+
((total_count++))
14+
done
15+
16+
echo "Total run $total_count"
17+
echo "Error count $error_count"

tests/test_polars.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import importlib.util
2+
import time
23
import unittest
3-
from unittest.mock import Mock
4+
from unittest.mock import Mock, ANY
45

56
from influxdb_client_3 import PointSettings, InfluxDBClient3, write_client_options, WriteOptions
67
from influxdb_client_3.write_client import WriteService
@@ -86,6 +87,12 @@ def test_write_polars_batching(self):
8687
data_frame_timestamp_column="time",
8788
)
8889

89-
actual = self.client._write_api._write_service.post_write.call_args[1]['body']
90-
self.assertEqual(b'measurement temperature=22.4 1722470400000000000\n'
91-
b'measurement temperature=21.8 1722474000000000000', actual)
90+
time.sleep(0.5)
91+
self.client._write_api._write_service.post_write.assert_called_once_with(
92+
org=ANY,
93+
bucket=ANY,
94+
precision=ANY,
95+
async_req=ANY,
96+
content_type=ANY,
97+
urlopen_kw=ANY,
98+
body=b'measurement temperature=22.4 1722470400000000000\nmeasurement temperature=21.8 1722474000000000000')

0 commit comments

Comments
 (0)