def test_accessor_list_mismatch(self): "The number of headings must match the number of accessors if specified as a list" with self.assertRaises(ValueError): build_accessors( headings=['First Col', 'Second Col', 'Third Col'], accessors=['first', 'second'] )
def __init__(self, headings, id=None, style=None, data=None, accessors=None, multiple_select=False, on_select=None, on_double_click=None, missing_value=None, factory=None): super().__init__(id=id, style=style, factory=factory) self.headings = headings[:] self._accessors = build_accessors(self.headings, accessors) self._multiple_select = multiple_select self._on_select = None self._on_double_click = None self._data = None if missing_value is None: print( "WARNING: Using empty string for missing value in data. " "Define a 'missing_value' on the table to silence this message" ) self._missing_value = missing_value or '' self._impl = self.factory.Table(interface=self) self.data = data self.on_select = on_select self.on_double_click = on_double_click
def test_partial_accessor_list(self): "None is interpreted as a default on an accessor override list" self.assertEqual( build_accessors( headings=['First Col', '2nd Col', 'Third Col'], accessors=[None, 'second', None] ), ['first_col', 'second', 'third_col'] )
def test_accessor_dict(self): "Accessor overrides can be specified as a dictionary" self.assertEqual( build_accessors( headings=['First Col', '2nd Col', 'Third Col'], accessors={'2nd Col': 'second'} ), ['first_col', 'second', 'third_col'] )
def test_manual_accessor_list(self): "Accessors can be compltely manually specified" self.assertEqual( build_accessors( headings=['First Col', 'Second Col', 'Third Col'], accessors=['first', 'second', 'third'] ), ['first', 'second', 'third'] )
def __init__(self, headings, id=None, style=None, data=None, accessors=None, multiple_select=False, on_select=None, factory=None): super().__init__(id=id, style=style, factory=factory) self.headings = headings self._accessors = build_accessors(headings, accessors) self._multiple_select = multiple_select self._on_select = None self._data = None self._impl = self.factory.Table(interface=self) self.data = data self.on_select = on_select
def __init__(self, headings, id=None, style=None, data=None, accessors=None, multiple_select=False, on_select=None, factory=None): super().__init__(id=id, style=style, factory=factory) self.headings = headings self._accessors = build_accessors(headings, accessors) self._multiple_select = multiple_select self._selection = None self._data = None self._on_select = None self._impl = self.factory.Tree(interface=self) self.data = data self.on_select = on_select
def test_accessor_dict(self): "Accessor overrides can be specified as a dictionary" self.assertEqual( build_accessors(headings=['First Col', '2nd Col', 'Third Col'], accessors={'2nd Col': 'second'}), ['first_col', 'second', 'third_col'])
def test_partial_accessor_list(self): "None is interpreted as a default on an accessor override list" self.assertEqual( build_accessors(headings=['First Col', '2nd Col', 'Third Col'], accessors=[None, 'second', None]), ['first_col', 'second', 'third_col'])
def test_manual_accessor_list(self): "Accessors can be compltely manually specified" self.assertEqual( build_accessors(headings=['First Col', 'Second Col', 'Third Col'], accessors=['first', 'second', 'third']), ['first', 'second', 'third'])
def test_accessor_list_mismatch(self): "The number of headings must match the number of accessors if specified as a list" with self.assertRaises(ValueError): build_accessors(headings=['First Col', 'Second Col', 'Third Col'], accessors=['first', 'second'])
def test_unique_accessors(self): "The final accessors must be unique" with self.assertRaises(ValueError): build_accessors(headings=['Col 1', 'Col - 1', 'Third Col'], accessors=None)
def test_autoconvert_failure(self): "If no accessors are provided, all the headings must be autoconvertable" with self.assertRaises(ValueError): build_accessors(headings=['1st Col', 'Second Col', 'Third Col'], accessors=None)
def test_autoconvert(self): "If no accessors are provided, the headings are autoconverted" self.assertEqual( build_accessors(headings=['First Col', 'Second Col', 'Third Col'], accessors=None), ['first_col', 'second_col', 'third_col'])
def test_autoconvert(self): "If no accessors are provided, the headings are autoconverted" self.assertEqual( build_accessors(headings=['First Col', 'Second Col', 'Third Col'], accessors=None), ['first_col', 'second_col', 'third_col'] )
def test_autoconvert_failure(self): "If no accessors are provided, all the headings must be autoconvertable" with self.assertRaises(ValueError): build_accessors(headings=['1st Col', 'Second Col', 'Third Col'], accessors=None)
def test_unique_accessors(self): "The final accessors must be unique" with self.assertRaises(ValueError): build_accessors(headings=['Col 1', 'Col - 1', 'Third Col'], accessors=None)