Skip to content

Commit 9213b6b

Browse files
committed
Merge pull request influxdata#97 from influxdb/dont_ignore_warnings
Dont ignore FutureWarnings in tests
2 parents c720f97 + 064f2d2 commit 9213b6b

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

influxdb/dataframe_client.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,13 @@ def write_points(self, data, *args, **kwargs):
5555
name=key,
5656
dataframe=data_frame.ix[start_index:end_index].copy(),
5757
time_precision=time_precision)]
58-
InfluxDBClient.write_points_with_precision(self, data,
59-
*args, **kwargs)
58+
InfluxDBClient.write_points(self, data, *args, **kwargs)
6059
return True
6160
else:
6261
data = [self._convert_dataframe_to_json(
6362
name=key, dataframe=dataframe, time_precision=time_precision)
6463
for key, dataframe in data.items()]
65-
return InfluxDBClient.write_points_with_precision(self, data,
66-
*args, **kwargs)
64+
return InfluxDBClient.write_points(self, data, *args, **kwargs)
6765

6866
def write_points_with_precision(self, data, time_precision='s'):
6967
"""

tests/influxdb/client_test.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ def request(*args, **kwargs):
6262
class TestInfluxDBClient(unittest.TestCase):
6363

6464
def setUp(self):
65-
# By default, ignore warnings
66-
warnings.simplefilter('ignore', FutureWarning)
65+
# By default, raise exceptions on warnings
66+
warnings.simplefilter('error', FutureWarning)
6767

6868
self.dummy_points = [
6969
{
@@ -92,7 +92,6 @@ def test_switch_database(self):
9292

9393
@raises(FutureWarning)
9494
def test_switch_db_deprecated(self):
95-
warnings.simplefilter('error', FutureWarning)
9695
cli = InfluxDBClient('host', 8086, 'username', 'password', 'database')
9796
cli.switch_db('another_database')
9897
assert cli._database == 'another_database'
@@ -170,7 +169,7 @@ def test_write_bad_precision_udp(self):
170169
Exception,
171170
"InfluxDB only supports seconds precision for udp writes"
172171
):
173-
cli.write_points_with_precision(
172+
cli.write_points(
174173
self.dummy_points,
175174
time_precision='ms'
176175
)
@@ -184,15 +183,15 @@ def test_write_points_fails(self):
184183
def test_write_points_with_precision(self):
185184
with _mocked_session('post', 200, self.dummy_points):
186185
cli = InfluxDBClient('host', 8086, 'username', 'password', 'db')
187-
assert cli.write_points_with_precision(self.dummy_points) is True
186+
assert cli.write_points(self.dummy_points) is True
188187

189188
def test_write_points_bad_precision(self):
190189
cli = InfluxDBClient()
191190
with self.assertRaisesRegexp(
192191
Exception,
193192
"Invalid time precision is given. \(use 's', 'm', 'ms' or 'u'\)"
194193
):
195-
cli.write_points_with_precision(
194+
cli.write_points(
196195
self.dummy_points,
197196
time_precision='g'
198197
)
@@ -325,7 +324,7 @@ def test_get_list_database(self):
325324
]
326325
with _mocked_session('get', 200, data):
327326
cli = InfluxDBClient('host', 8086, 'username', 'password')
328-
assert len(cli.get_database_list()) == 1
327+
assert len(cli.get_list_database()) == 1
329328
assert cli.get_list_database()[0]['name'] == 'a_db'
330329

331330
@raises(Exception)
@@ -336,7 +335,6 @@ def test_get_list_database_fails(self):
336335

337336
@raises(FutureWarning)
338337
def test_get_database_list_deprecated(self):
339-
warnings.simplefilter('error', FutureWarning)
340338
data = [
341339
{"name": "a_db"}
342340
]

tests/influxdb/dataframe_client_test.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from datetime import timedelta
1010
from tests import skipIfPYpy, using_pypy
1111
import copy
12+
import warnings
1213

1314
if not using_pypy:
1415
import pandas as pd
@@ -21,6 +22,10 @@
2122
@skipIfPYpy
2223
class TestDataFrameClient(unittest.TestCase):
2324

25+
def setUp(self):
26+
# By default, raise exceptions on warnings
27+
warnings.simplefilter('error', FutureWarning)
28+
2429
def test_write_points_from_dataframe(self):
2530
now = pd.Timestamp('1970-01-01 00:00+00:00')
2631
dataframe = pd.DataFrame(data=[["1", 1, 1.0], ["2", 2, 2.0]],

0 commit comments

Comments
 (0)