@@ -532,14 +532,30 @@ class TestMsgpack():
532
532
http://stackoverflow.com/questions/6689537/nose-test-generators-inside-class
533
533
"""
534
534
def setUp (self ):
535
- from pandas .io .tests .generate_legacy_storage_files import create_msgpack_data
535
+ from pandas .io .tests .generate_legacy_storage_files import (
536
+ create_msgpack_data , create_data )
536
537
self .data = create_msgpack_data ()
538
+ self .all_data = create_data ()
537
539
self .path = u ('__%s__.msgpack' % tm .rands (10 ))
540
+ self .minimum_structure = {'series' : ['float' , 'int' , 'mixed' , 'ts' , 'mi' , 'dup' ],
541
+ 'frame' : ['float' , 'int' , 'mixed' , 'mi' ],
542
+ 'panel' : ['float' ],
543
+ 'index' : ['int' , 'date' , 'period' ],
544
+ 'mi' : ['reg2' ]}
545
+
546
+ def check_min_structure (self , data ):
547
+ for typ , v in self .minimum_structure .items ():
548
+ assert typ in data , '"{0}" not found in unpacked data' .format (typ )
549
+ for kind in v :
550
+ assert kind in data [typ ], '"{0}" not found in data["{1}"]' .format (kind , typ )
538
551
539
552
def compare (self , vf ):
540
553
data = read_msgpack (vf )
554
+ self .check_min_structure (data )
541
555
for typ , dv in data .items ():
556
+ assert typ in self .all_data , 'unpacked data contains extra key "{0}"' .format (typ )
542
557
for dt , result in dv .items ():
558
+ assert dt in self .all_data [typ ], 'data["{0}"] contains extra key "{1}"' .format (typ , dt )
543
559
try :
544
560
expected = self .data [typ ][dt ]
545
561
except KeyError :
0 commit comments