2
2
import glob
3
3
from io import BytesIO
4
4
import os
5
- from warnings import catch_warnings
5
+ from warnings import catch_warnings , filterwarnings
6
6
7
7
import numpy as np
8
8
import pytest
@@ -83,6 +83,7 @@ def check_arbitrary(a, b):
83
83
assert (a == b )
84
84
85
85
86
+ @pytest .mark .filterwarnings ("ignore:.*msgpack:FutureWarning" )
86
87
class TestPackers :
87
88
88
89
def setup_method (self , method ):
@@ -97,6 +98,7 @@ def encode_decode(self, x, compress=None, **kwargs):
97
98
return read_msgpack (p , ** kwargs )
98
99
99
100
101
+ @pytest .mark .filterwarnings ("ignore:.*msgpack:FutureWarning" )
100
102
class TestAPI (TestPackers ):
101
103
102
104
def test_string_io (self ):
@@ -159,6 +161,7 @@ def __init__(self):
159
161
read_msgpack (path_or_buf = A ())
160
162
161
163
164
+ @pytest .mark .filterwarnings ("ignore:.*msgpack:FutureWarning" )
162
165
class TestNumpy (TestPackers ):
163
166
164
167
def test_numpy_scalar_float (self ):
@@ -277,6 +280,7 @@ def test_list_mixed(self):
277
280
tm .assert_almost_equal (tuple (x ), x_rec )
278
281
279
282
283
+ @pytest .mark .filterwarnings ("ignore:.*msgpack:FutureWarning" )
280
284
class TestBasic (TestPackers ):
281
285
282
286
def test_timestamp (self ):
@@ -322,6 +326,7 @@ def test_intervals(self):
322
326
assert i == i_rec
323
327
324
328
329
+ @pytest .mark .filterwarnings ("ignore:.*msgpack:FutureWarning" )
325
330
class TestIndex (TestPackers ):
326
331
327
332
def setup_method (self , method ):
@@ -387,6 +392,7 @@ def categorical_index(self):
387
392
tm .assert_frame_equal (result , df )
388
393
389
394
395
+ @pytest .mark .filterwarnings ("ignore:.*msgpack:FutureWarning" )
390
396
class TestSeries (TestPackers ):
391
397
392
398
def setup_method (self , method ):
@@ -437,6 +443,7 @@ def test_basic(self):
437
443
assert_series_equal (i , i_rec )
438
444
439
445
446
+ @pytest .mark .filterwarnings ("ignore:.*msgpack:FutureWarning" )
440
447
class TestCategorical (TestPackers ):
441
448
442
449
def setup_method (self , method ):
@@ -460,6 +467,7 @@ def test_basic(self):
460
467
assert_categorical_equal (i , i_rec )
461
468
462
469
470
+ @pytest .mark .filterwarnings ("ignore:msgpack:FutureWarning" )
463
471
class TestNDFrame (TestPackers ):
464
472
465
473
def setup_method (self , method ):
@@ -549,6 +557,7 @@ def test_dataframe_duplicate_column_names(self):
549
557
@pytest .mark .filterwarnings ("ignore:Sparse:FutureWarning" )
550
558
@pytest .mark .filterwarnings ("ignore:Series.to_sparse:FutureWarning" )
551
559
@pytest .mark .filterwarnings ("ignore:DataFrame.to_sparse:FutureWarning" )
560
+ @pytest .mark .filterwarnings ("ignore:.*msgpack:FutureWarning" )
552
561
class TestSparse (TestPackers ):
553
562
554
563
def _check_roundtrip (self , obj , comparator , ** kwargs ):
@@ -595,6 +604,7 @@ def test_sparse_frame(self):
595
604
check_frame_type = True )
596
605
597
606
607
+ @pytest .mark .filterwarnings ("ignore:.*msgpack:FutureWarning" )
598
608
class TestCompression (TestPackers ):
599
609
"""See https://github.com/pandas-dev/pandas/pull/9783
600
610
"""
@@ -676,18 +686,21 @@ def decompress(ob):
676
686
with monkeypatch .context () as m , \
677
687
tm .assert_produces_warning (PerformanceWarning ) as ws :
678
688
m .setattr (compress_module , 'decompress' , decompress )
679
- i_rec = self .encode_decode (self .frame , compress = compress )
680
- for k in self .frame .keys ():
681
-
682
- value = i_rec [k ]
683
- expected = self .frame [k ]
684
- assert_frame_equal (value , expected )
685
- # make sure that we can write to the new frames even though
686
- # we needed to copy the data
687
- for block in value ._data .blocks :
688
- assert block .values .flags .writeable
689
- # mutate the data in some way
690
- block .values [0 ] += rhs [block .dtype ]
689
+
690
+ with catch_warnings ():
691
+ filterwarnings ('ignore' , category = FutureWarning )
692
+ i_rec = self .encode_decode (self .frame , compress = compress )
693
+ for k in self .frame .keys ():
694
+
695
+ value = i_rec [k ]
696
+ expected = self .frame [k ]
697
+ assert_frame_equal (value , expected )
698
+ # make sure that we can write to the new frames even though
699
+ # we needed to copy the data
700
+ for block in value ._data .blocks :
701
+ assert block .values .flags .writeable
702
+ # mutate the data in some way
703
+ block .values [0 ] += rhs [block .dtype ]
691
704
692
705
for w in ws :
693
706
# check the messages from our warnings
@@ -715,14 +728,18 @@ def test_compression_warns_when_decompress_caches_blosc(self, monkeypatch):
715
728
def _test_small_strings_no_warn (self , compress ):
716
729
empty = np .array ([], dtype = 'uint8' )
717
730
with tm .assert_produces_warning (None ):
718
- empty_unpacked = self .encode_decode (empty , compress = compress )
731
+ with catch_warnings ():
732
+ filterwarnings ('ignore' , category = FutureWarning )
733
+ empty_unpacked = self .encode_decode (empty , compress = compress )
719
734
720
735
tm .assert_numpy_array_equal (empty_unpacked , empty )
721
736
assert empty_unpacked .flags .writeable
722
737
723
738
char = np .array ([ord (b'a' )], dtype = 'uint8' )
724
739
with tm .assert_produces_warning (None ):
725
- char_unpacked = self .encode_decode (char , compress = compress )
740
+ with catch_warnings ():
741
+ filterwarnings ('ignore' , category = FutureWarning )
742
+ char_unpacked = self .encode_decode (char , compress = compress )
726
743
727
744
tm .assert_numpy_array_equal (char_unpacked , char )
728
745
assert char_unpacked .flags .writeable
@@ -794,6 +811,7 @@ def test_readonly_axis_zlib_to_sql(self):
794
811
assert_frame_equal (expected , result )
795
812
796
813
814
+ @pytest .mark .filterwarnings ("ignore:.*msgpack:FutureWarning" )
797
815
class TestEncoding (TestPackers ):
798
816
799
817
def setup_method (self , method ):
@@ -839,6 +857,7 @@ def legacy_packer(request, datapath):
839
857
840
858
841
859
@pytest .mark .filterwarnings ("ignore:Sparse:FutureWarning" )
860
+ @pytest .mark .filterwarnings ("ignore:.*msgpack:FutureWarning" )
842
861
class TestMsgpack :
843
862
"""
844
863
How to add msgpack tests:
0 commit comments