def test_simple(self): "Simple cases can be converted" self.assertEqual(to_accessor('hello'), 'hello') self.assertEqual(to_accessor('Hello'), 'hello') self.assertEqual(to_accessor('Hello1'), 'hello1') self.assertEqual(to_accessor('Hello 1'), 'hello_1') self.assertEqual(to_accessor('Hello world'), 'hello_world') self.assertEqual(to_accessor('Hello World'), 'hello_world') self.assertEqual(to_accessor('Hello World 1'), 'hello_world_1') self.assertEqual(to_accessor('Hello World 1!'), 'hello_world_1') self.assertEqual(to_accessor('Hello!$@# World!^&*('), 'hello_world')
def test_simple(self): "Simple cases can be converted" self.assertEqual(to_accessor('hello'), 'hello') self.assertEqual(to_accessor('Hello'), 'hello') self.assertEqual(to_accessor('Hello1'), 'hello1') self.assertEqual(to_accessor('Hello 1'), 'hello_1') self.assertEqual(to_accessor('Hello world'), 'hello_world') self.assertEqual(to_accessor('Hello World'), 'hello_world') self.assertEqual(to_accessor('Hello World 1'), 'hello_world_1') self.assertEqual(to_accessor('Hello World 1!'), 'hello_world_1') self.assertEqual(to_accessor('Hello!$@# World!^&*('), 'hello_world')
def add_column(self, heading, accessor=None): """ Add a new column to the table :param heading: title of the column :type heading: ``string`` :param accessor: accessor of this new column :type heading: ``string`` """ if not accessor: accessor = to_accessor(heading) if accessor in self._accessors: raise ValueError('Accessor "{}" is already in use'.format(accessor)) self.headings.append(heading) self._accessors.append(accessor) self._impl.add_column(heading, accessor)
def test_symbols_only(self): "A symbol-only name can't be automatically generated" with self.assertRaises(ValueError): to_accessor('$*(!&*@&^*&^!')
def test_digit_first(self): "A digit-first name can't be automatically generated" with self.assertRaises(ValueError): to_accessor('101 Dalmations')
def test_whitespace_duplicates(self): "Multiple whitespace characters are collapsed, after other substitutions have been performed" self.assertEqual(to_accessor('Hello - World'), 'hello_world')
def test_symbols_only(self): "A symbol-only name can't be automatically generated" with self.assertRaises(ValueError): to_accessor('$*(!&*@&^*&^!')
def test_digit_first(self): "A digit-first name can't be automatically generated" with self.assertRaises(ValueError): to_accessor('101 Dalmations')
def test_whitespace_duplicates(self): "Multiple whitespace characters are collapsed, after other substitutions have been performed" self.assertEqual(to_accessor('Hello - World'), 'hello_world')