diff options
author | John Ehresman <jpe@src.gnome.org> | 2004-07-04 19:44:27 +0000 |
---|---|---|
committer | John Ehresman <jpe@src.gnome.org> | 2004-07-04 19:44:27 +0000 |
commit | 86c0830f4b4151fce5a94f831b885f2eff9fa2f2 (patch) | |
tree | 7812c5a90c21c974dbc5572a1183877397e08980 | |
parent | 072186406de2ea403ade8474f5873d8137d9218c (diff) | |
download | pygobject-86c0830f4b4151fce5a94f831b885f2eff9fa2f2.tar.gz pygobject-86c0830f4b4151fce5a94f831b885f2eff9fa2f2.tar.xz pygobject-86c0830f4b4151fce5a94f831b885f2eff9fa2f2.zip |
tests directory: unit tests
-rw-r--r-- | tests/testconversion.py | 47 | ||||
-rw-r--r-- | tests/testsupport.py | 30 |
2 files changed, 77 insertions, 0 deletions
diff --git a/tests/testconversion.py b/tests/testconversion.py new file mode 100644 index 0000000..63d08f4 --- /dev/null +++ b/tests/testconversion.py @@ -0,0 +1,47 @@ +# -*- Mode: Python; py-indent-offset: 4 -*- + +import unittest +import testsupport + +import gtk + +class Tests(unittest.TestCase): + + def testUnicharArg(self): + """ Test unichar values when used as arguments. """ + + entry = gtk.Entry() + for valid_value in ['a', u'b', u'\ufff0', u'\ufff0'.encode()]: + entry.set_invisible_char(valid_value) + assert entry.get_invisible_char() == unicode(valid_value) + + for invalid_value in ['12', None, 1, '']: + try: + entry.set_invisible_char(invalid_value) + except: + pass + else: + raise AssertionError('exception not raised on invalid value w/ set_invisible_char: %s' + % invalid_value) + + def failtestUnicharProperty(self): + """ Test unichar values when used as arguments. """ + + entry = gtk.Entry() + for valid_value in ['a', u'b', u'\ufff0', u'\ufff0'.encode()]: + entry.set_property('invisible_char', valid_value) + assert entry.get_property('invisible_char') == valid_value + + for invalid_value in ['12', None, 1, '']: + try: + entry.set_property('invisible_char', invalid_value) + except: + pass + else: + raise AssertionError('exception not raised on invalid value w/ set_property: %s' + % invalid_value) +def main(): + testsupport.run_all_tests() + +if __name__ == '__main__': + main()
\ No newline at end of file diff --git a/tests/testsupport.py b/tests/testsupport.py new file mode 100644 index 0000000..bc23975 --- /dev/null +++ b/tests/testsupport.py @@ -0,0 +1,30 @@ +# -*- Mode: Python; py-indent-offset: 4 -*- + +import sys +import os +import unittest +import __main__ + +# Insert parent directory into path +def insert_pygtk_python_paths(): + try: + filename = __file__ + except: + filename = sys.argv[0] + this_dir = os.path.dirname(os.path.abspath(filename)) + parent_dir = os.path.dirname(this_dir) + sys.path.insert(0, parent_dir) + +insert_pygtk_python_paths() + +def run_all_tests(mods = [__main__]): + runner = unittest.TextTestRunner() + for mod in mods: + for name in dir(mod): + val = getattr(mod, name) + try: + if issubclass(val, unittest.TestCase): + suite = unittest.makeSuite(val, 'test') + runner.run(suite) + except TypeError: + pass |