diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_everything.py | 1 | ||||
-rw-r--r-- | tests/test_gi.py | 30 | ||||
-rw-r--r-- | tests/test_overrides.py | 4 |
3 files changed, 34 insertions, 1 deletions
diff --git a/tests/test_everything.py b/tests/test_everything.py index 74d917a..5fadc36 100644 --- a/tests/test_everything.py +++ b/tests/test_everything.py @@ -11,7 +11,6 @@ from sys import getrefcount import cairo from gi.repository import GObject -from gi.repository import GLib from gi.repository import Regress as Everything if sys.version_info < (3, 0): diff --git a/tests/test_gi.py b/tests/test_gi.py index 4aa5532..6990225 100644 --- a/tests/test_gi.py +++ b/tests/test_gi.py @@ -5,6 +5,11 @@ import sys import unittest +import tempfile +import shutil +import os +import locale +import subprocess from gi.repository import GObject import gobject @@ -960,6 +965,31 @@ class TestPointer(unittest.TestCase): class TestEnum(unittest.TestCase): + @classmethod + def setUpClass(cls): + '''Run tests under a test locale. + + Upper case conversion of member names should not be locale specific; + e. g. in Turkish, "i".upper() == "i", which gives results like "iNVALiD" + + Run test under a locale which defines toupper('a') == 'a' + ''' + cls.locale_dir = tempfile.mkdtemp() + subprocess.check_call(['localedef', '-i', + os.path.join(os.path.dirname(os.path.realpath(__file__)), 'te_ST@nouppera'), + '-c', '-f', 'UTF-8', os.path.join(cls.locale_dir, 'te_ST.UTF-8@nouppera')]) + os.environ['LOCPATH'] = cls.locale_dir + locale.setlocale(locale.LC_ALL, 'te_ST.UTF-8@nouppera') + + @classmethod + def tearDownClass(cls): + locale.setlocale(locale.LC_ALL, 'C') + shutil.rmtree(cls.locale_dir) + try: + del os.environ['LOCPATH'] + except KeyError: + pass + def test_enum(self): self.assertTrue(issubclass(GIMarshallingTests.Enum, int)) self.assertTrue(isinstance(GIMarshallingTests.Enum.VALUE1, GIMarshallingTests.Enum)) diff --git a/tests/test_overrides.py b/tests/test_overrides.py index 57abdfd..47f38a3 100644 --- a/tests/test_overrides.py +++ b/tests/test_overrides.py @@ -359,10 +359,14 @@ class TestGdk(unittest.TestCase): self.assertEquals(color.red, 100) self.assertEquals(color.green, 200) self.assertEquals(color.blue, 300) + self.assertEquals(color, Gdk.Color(100, 200, 300)) + self.assertNotEquals(color, Gdk.Color(1, 2, 3)) def test_rgba(self): self.assertEquals(Gdk.RGBA, overrides.Gdk.RGBA) rgba = Gdk.RGBA(0.1, 0.2, 0.3, 0.4) + self.assertEquals(rgba, Gdk.RGBA(0.1, 0.2, 0.3, 0.4)) + self.assertNotEquals(rgba, Gdk.RGBA(0.0, 0.2, 0.3, 0.4)) self.assertEquals(rgba.red, 0.1) self.assertEquals(rgba.green, 0.2) self.assertEquals(rgba.blue, 0.3) |