def test_add_column(mixin_cols):
 attrs = ('name', 'unit', 'dtype', 'format', 'description', 'meta')
 m = mixin_cols['m']
 assert (m.info.name is None)
 t = QTable([m], names=['a'])
 assert (m.info.name is None)
 t['new'] = m
 assert (m.info.name is None)
 m.info.name = 'm'
 m.info.format = '{0}'
 m.info.description = 'd'
 m.info.meta = {'a': 1}
 t = QTable([m])
 t['m2'] = m
 m.info.name = 'm3'
 t.add_columns([m], copy=True)
 m.info.name = 'm4'
 t.add_columns([m], copy=False)
 for name in ('m2', 'm3', 'm4'):
  assert_table_name_col_equal(t, 'm', t[name])
  for attr in attrs:
   if (attr != 'name'):
    assert (getattr(t['m'].info, attr) == getattr(t[name].info, attr))

def test_add_column ( mixin_cols ) : attrs = ( 'name' , 'unit' , 'dtype' , 'format' , 'description' , 'meta' ) m = mixin_cols [ 'm' ] assert ( m . info . name is None ) t = QTable ( [ m ] , names = [ 'a' ] ) assert ( m . info . name is None ) t [ 'new' ] = m assert ( m . info . name is None ) m . info . name = 'm' m . info . format = '{0}' m . info . description = 'd' m . info . meta = { 'a' : 1 } t = QTable ( [ m ] ) t [ 'm2' ] = m m . info . name = 'm3' t . add_columns ( [ m ] , copy = True ) m . info . name = 'm4' t . add_columns ( [ m ] , copy = False ) for name in ( 'm2' , 'm3' , 'm4' ) : assert_table_name_col_equal ( t , 'm' , t [ name ] ) for attr in attrs : if ( attr != 'name' ) : assert ( getattr ( t [ 'm' ] . info , attr ) == getattr ( t [ name ] . info , attr ) )
test that adding a column preserves values and attributes .