From 42f0ec4d3df42225eaea431afed1dc577a5463d8 Mon Sep 17 00:00:00 2001 From: Gabriel Studer <gabriel.studer@stud.unibas.ch> Date: Tue, 25 Jun 2013 15:13:43 +0200 Subject: [PATCH] fixed glitch and tested the observation described in the last commit message --- modules/base/pymod/table.py | 3 ++- modules/base/tests/test_table.py | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/base/pymod/table.py b/modules/base/pymod/table.py index c4031d010..e5de1d5bf 100644 --- a/modules/base/pymod/table.py +++ b/modules/base/pymod/table.py @@ -218,7 +218,8 @@ class Table(object): SUPPORTED_TYPES=('int', 'float', 'bool', 'string',) - def __init__(self, col_names=None, col_types=None, **kwargs): + def __init__(self, col_names=[], col_types=None, **kwargs): + self.col_names=list(col_names) self.comment='' self.name='' diff --git a/modules/base/tests/test_table.py b/modules/base/tests/test_table.py index 731acc185..3cacb6b9f 100644 --- a/modules/base/tests/test_table.py +++ b/modules/base/tests/test_table.py @@ -218,7 +218,11 @@ class TestTable(unittest.TestCase): self.CompareColCount(tab, 0) self.CompareRowCount(tab, 0) self.assertRaises(ValueError, tab.GetColIndex, 'a') - + def testTableInitFromOldTable(self): + old_tab = Table(['a','b'],'ff') + new_tab = Table(old_tab.col_names,old_tab.col_types) + new_tab.AddCol('c','f') + self.assertEqual(old_tab.col_names, ['a','b']) def testGuessColumnType(self): self.assertEqual(GuessColumnType(['1', '1.3', '2']), 'float') self.assertEqual(GuessColumnType(['1', '1', '2']), 'int') -- GitLab