Skip to content

Commit

Permalink
Add a test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-fabian committed Aug 3, 2018
1 parent 672455c commit d9cf5f1
Show file tree
Hide file tree
Showing 13 changed files with 1,153 additions and 146 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ ibus-table.spec
/missing
/py-compile
ibus-table-*.tar.gz
test-driver
*~
1 change: 1 addition & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ SUBDIRS = \
data \
po \
setup \
tests \
$(NULL)

ACLOCAL_AMFLAGS = -I m4
Expand Down
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ AC_CONFIG_FILES([po/Makefile.in
setup/Makefile
setup/ibus-setup-table
setup/version.py
tests/Makefile
ibus-table.spec
ibus-table.pc]
)
Expand Down
1 change: 1 addition & 0 deletions engine/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ engine_table_PYTHON = \
table.py \
tabcreatedb.py \
tabsqlitedb.py \
it_util.py \
$(NULL)
engine_table_DATA = \
$(NULL)
Expand Down
63 changes: 63 additions & 0 deletions engine/it_util.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# -*- coding: utf-8 -*-
# vim:et sts=4 sw=4
#
# ibus-table - The Tables engine for IBus
#
# Copyright (c) 2008-2009 Yu Yuwei <acevery@gmail.com>
# Copyright (c) 2009-2014 Caius "kaio" CHANCE <me@kaio.net>
# Copyright (c) 2012-2015 Mike FABIAN <mfabian@redhat.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#
'''
Utility functions used in ibus-table
'''

import sys
import re
import string

def config_section_normalize(section):
'''Replaces “_:” with “-” in the dconf section and converts to lower case
:param section: The name of the dconf section
:type section: string
:rtype: string
To make the comparison of the dconf sections work correctly.
I avoid using .lower() here because it is locale dependent, when
using .lower() this would not achieve the desired effect of
comparing the dconf sections case insentively in some locales, it
would fail for example if Turkish locale (tr_TR.UTF-8) is set.
Examples:
>>> config_section_normalize('Foo_bAr:Baz')
'foo-bar-baz'
'''
return re.sub(r'[_:]', r'-', section).translate(
bytes.maketrans(
bytes(string.ascii_uppercase.encode('ascii')),
bytes(string.ascii_lowercase.encode('ascii'))))


if __name__ == "__main__":
import doctest
(FAILED, ATTEMPTED) = doctest.testmod()
if FAILED:
sys.exit(1)
else:
sys.exit(0)
Loading

0 comments on commit d9cf5f1

Please sign in to comment.