@@ -51,7 +51,7 @@ def test_table_info_attributes(table_types):
5151 assert np .all (tinfo ['unit' ] == ['' , '' , '' , 'm' , '' , 'deg,deg' ])
5252 assert np .all (tinfo ['format' ] == ['%02d' , '' , '' , '' , '' , '' ])
5353 assert np .all (tinfo ['description' ] == ['' , '' , '' , 'quantity' , 'time' , 'skycoord' ])
54- cls = 'MyColumn' if subcls else ''
54+ cls = t . ColumnClass . __name__
5555 assert np .all (tinfo ['class' ] == [cls , cls , cls , cls , 'Time' , 'SkyCoord' ])
5656
5757def test_table_info_stats (table_types ):
@@ -128,7 +128,7 @@ def test_data_info():
128128 ('unit' , 'm / s' ),
129129 ('format' , '' ),
130130 ('description' , 'description' ),
131- ('class' , '' ),
131+ ('class' , type ( c ). __name__ ),
132132 ('n_bad' , 1 ),
133133 ('length' , 3 )])
134134
@@ -139,6 +139,7 @@ def test_data_info():
139139 'dtype = float64' ,
140140 'unit = m / s' ,
141141 'description = description' ,
142+ 'class = {0}' .format (type (c ).__name__ ),
142143 'n_bad = 1' ,
143144 'length = 3' ]
144145 assert out .getvalue ().splitlines () == exp
@@ -163,16 +164,17 @@ class Column(table.Column):
163164 Confusingly named Column on purpose, but that is legal.
164165 """
165166 pass
166- c = Column ([1 , 2 ], dtype = 'int64' )
167- cinfo = c .info (out = None )
168- assert cinfo == OrderedDict ([('dtype' , 'int64' ),
169- ('shape' , '' ),
170- ('unit' , '' ),
171- ('format' , '' ),
172- ('description' , '' ),
173- ('class' , 'Column' ),
174- ('n_bad' , 0 ),
175- ('length' , 2 )])
167+ for data in ([], [1 , 2 ]):
168+ c = Column (data , dtype = 'int64' )
169+ cinfo = c .info (out = None )
170+ assert cinfo == OrderedDict ([('dtype' , 'int64' ),
171+ ('shape' , '' ),
172+ ('unit' , '' ),
173+ ('format' , '' ),
174+ ('description' , '' ),
175+ ('class' , 'Column' ),
176+ ('n_bad' , 0 ),
177+ ('length' , len (data ))])
176178
177179
178180def test_scalar_info ():
@@ -183,3 +185,11 @@ def test_scalar_info():
183185 cinfo = c .info (out = None )
184186 assert cinfo ['n_bad' ] == 0
185187 assert 'length' not in cinfo
188+
189+
190+ def test_empty_table ():
191+ t = table .Table ()
192+ out = six .moves .cStringIO ()
193+ t .info (out = out )
194+ exp = ['<Table length=0>' , '<No columns>' ]
195+ assert out .getvalue ().splitlines () == exp
0 commit comments