diff options
author | Christoph Reiter <creiter@src.gnome.org> | 2017-10-13 14:32:44 +0200 |
---|---|---|
committer | Christoph Reiter <creiter@src.gnome.org> | 2017-10-13 14:34:48 +0200 |
commit | f40df0a09803ec9c729d842f1f83c6d56aebac22 (patch) | |
tree | 956dd614255c0c1042178c5952b7e090f8016ace /tests/test_gi.py | |
parent | 857fb023886476988d99d35c92894cdbc1bbeab2 (diff) | |
download | pygobject-f40df0a09803ec9c729d842f1f83c6d56aebac22.tar.gz |
tests: Make the test suite pass with the C locale
Some filename tests assumed a Unicode locale, skip those.
Diffstat (limited to 'tests/test_gi.py')
-rw-r--r-- | tests/test_gi.py | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/tests/test_gi.py b/tests/test_gi.py index 8a9bb2ce..7eb9c997 100644 --- a/tests/test_gi.py +++ b/tests/test_gi.py @@ -695,6 +695,13 @@ class TestFilename(unittest.TestCase): @unittest.skipIf(os.name == "nt", "fixme") def test_filename_in(self): fname = os.path.join(self.workdir, u'testäø.txt') + + try: + os.path.exists(fname) + except ValueError: + # non-unicode fs encoding + return + self.assertRaises(GLib.GError, GLib.file_get_contents, fname) with open(fname.encode('UTF-8'), 'wb') as f: @@ -711,8 +718,15 @@ class TestFilename(unittest.TestCase): @unittest.skipIf(os.name == "nt", "fixme") def test_filename_out(self): self.assertRaises(GLib.GError, GLib.Dir.make_tmp, 'test') + name = 'testäø.XXXXXX' + + try: + os.path.exists(name) + except ValueError: + # non-unicode fs encoding + return - dirname = GLib.Dir.make_tmp('testäø.XXXXXX') + dirname = GLib.Dir.make_tmp(name) self.assertTrue(os.path.sep + 'testäø.' in dirname, dirname) self.assertTrue(os.path.isdir(dirname)) os.rmdir(dirname) @@ -857,7 +871,8 @@ class TestFilename(unittest.TestCase): wd = self.workdir wdb = os.fsencode(wd) if PY3 else wd - paths = [(wdb, b"foo-1"), (wd, u"foo-2"), (wd, u"öäü-3")] + paths = [(wdb, b"foo-1"), (wd, u"foo-2"), (wd, u"öäü-3"), + (wdb, b"\xff\xfe-5")] if PY3: try: paths.append((wd, os.fsdecode(b"\xff\xfe-4"))) @@ -865,10 +880,16 @@ class TestFilename(unittest.TestCase): # depends on the code page pass - if os.name != "nt": - paths.append((wdb, b"\xff\xfe-5")) + def valid_path(p): + try: + os.path.exists(p) + except ValueError: + return False + return True for (d, path) in paths: + if not valid_path(path): + continue path = os.path.join(d, path) with open(path, "wb"): self.assertTrue(GIMarshallingTests.filename_exists(path)) |