22import glob
33from io import BytesIO
44import os
5- from warnings import catch_warnings
5+ from warnings import catch_warnings , filterwarnings
66
77import numpy as np
88import pytest
@@ -83,6 +83,7 @@ def check_arbitrary(a, b):
8383 assert (a == b )
8484
8585
86+ @pytest .mark .filterwarnings ("ignore:.*msgpack:FutureWarning" )
8687class TestPackers :
8788
8889 def setup_method (self , method ):
@@ -97,6 +98,7 @@ def encode_decode(self, x, compress=None, **kwargs):
9798 return read_msgpack (p , ** kwargs )
9899
99100
101+ @pytest .mark .filterwarnings ("ignore:.*msgpack:FutureWarning" )
100102class TestAPI (TestPackers ):
101103
102104 def test_string_io (self ):
@@ -159,6 +161,7 @@ def __init__(self):
159161 read_msgpack (path_or_buf = A ())
160162
161163
164+ @pytest .mark .filterwarnings ("ignore:.*msgpack:FutureWarning" )
162165class TestNumpy (TestPackers ):
163166
164167 def test_numpy_scalar_float (self ):
@@ -277,6 +280,7 @@ def test_list_mixed(self):
277280 tm .assert_almost_equal (tuple (x ), x_rec )
278281
279282
283+ @pytest .mark .filterwarnings ("ignore:.*msgpack:FutureWarning" )
280284class TestBasic (TestPackers ):
281285
282286 def test_timestamp (self ):
@@ -322,6 +326,7 @@ def test_intervals(self):
322326 assert i == i_rec
323327
324328
329+ @pytest .mark .filterwarnings ("ignore:.*msgpack:FutureWarning" )
325330class TestIndex (TestPackers ):
326331
327332 def setup_method (self , method ):
@@ -387,6 +392,7 @@ def categorical_index(self):
387392 tm .assert_frame_equal (result , df )
388393
389394
395+ @pytest .mark .filterwarnings ("ignore:.*msgpack:FutureWarning" )
390396class TestSeries (TestPackers ):
391397
392398 def setup_method (self , method ):
@@ -437,6 +443,7 @@ def test_basic(self):
437443 assert_series_equal (i , i_rec )
438444
439445
446+ @pytest .mark .filterwarnings ("ignore:.*msgpack:FutureWarning" )
440447class TestCategorical (TestPackers ):
441448
442449 def setup_method (self , method ):
@@ -460,6 +467,7 @@ def test_basic(self):
460467 assert_categorical_equal (i , i_rec )
461468
462469
470+ @pytest .mark .filterwarnings ("ignore:msgpack:FutureWarning" )
463471class TestNDFrame (TestPackers ):
464472
465473 def setup_method (self , method ):
@@ -549,6 +557,7 @@ def test_dataframe_duplicate_column_names(self):
549557@pytest .mark .filterwarnings ("ignore:Sparse:FutureWarning" )
550558@pytest .mark .filterwarnings ("ignore:Series.to_sparse:FutureWarning" )
551559@pytest .mark .filterwarnings ("ignore:DataFrame.to_sparse:FutureWarning" )
560+ @pytest .mark .filterwarnings ("ignore:.*msgpack:FutureWarning" )
552561class TestSparse (TestPackers ):
553562
554563 def _check_roundtrip (self , obj , comparator , ** kwargs ):
@@ -595,6 +604,7 @@ def test_sparse_frame(self):
595604 check_frame_type = True )
596605
597606
607+ @pytest .mark .filterwarnings ("ignore:.*msgpack:FutureWarning" )
598608class TestCompression (TestPackers ):
599609 """See https://github.com/pandas-dev/pandas/pull/9783
600610 """
@@ -676,18 +686,21 @@ def decompress(ob):
676686 with monkeypatch .context () as m , \
677687 tm .assert_produces_warning (PerformanceWarning ) as ws :
678688 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 ]
691704
692705 for w in ws :
693706 # check the messages from our warnings
@@ -715,14 +728,18 @@ def test_compression_warns_when_decompress_caches_blosc(self, monkeypatch):
715728 def _test_small_strings_no_warn (self , compress ):
716729 empty = np .array ([], dtype = 'uint8' )
717730 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 )
719734
720735 tm .assert_numpy_array_equal (empty_unpacked , empty )
721736 assert empty_unpacked .flags .writeable
722737
723738 char = np .array ([ord (b'a' )], dtype = 'uint8' )
724739 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 )
726743
727744 tm .assert_numpy_array_equal (char_unpacked , char )
728745 assert char_unpacked .flags .writeable
@@ -794,6 +811,7 @@ def test_readonly_axis_zlib_to_sql(self):
794811 assert_frame_equal (expected , result )
795812
796813
814+ @pytest .mark .filterwarnings ("ignore:.*msgpack:FutureWarning" )
797815class TestEncoding (TestPackers ):
798816
799817 def setup_method (self , method ):
@@ -839,6 +857,7 @@ def legacy_packer(request, datapath):
839857
840858
841859@pytest .mark .filterwarnings ("ignore:Sparse:FutureWarning" )
860+ @pytest .mark .filterwarnings ("ignore:.*msgpack:FutureWarning" )
842861class TestMsgpack :
843862 """
844863 How to add msgpack tests:
0 commit comments