diff --git a/gio/tests/codegen.py b/gio/tests/codegen.py index d2d8c72263cac493011f9f6b7847a761ae42f559..bee59eeb1617a1456552a73004b97cd70774ef32 100644 --- a/gio/tests/codegen.py +++ b/gio/tests/codegen.py @@ -95,7 +95,12 @@ class TestCodegen(unittest.TestCase): env = os.environ.copy() env["LC_ALL"] = "C.UTF-8" - print("Environment:", env) + try: + print("Environment:", env) + except UnicodeEncodeError: + # Can happen if the environment contains non-ASCII bytes but the + # environment we’re running in wants output in a different locale. + pass # We want to ensure consistent line endings... info = subprocess.run( diff --git a/glib/tests/assert-msg-test.py b/glib/tests/assert-msg-test.py index 4936fa08322fc573cabf8e1a79f79e9129a4ef70..f97ed59b0302debf9857fd111cc08d01a14209cd 100755 --- a/glib/tests/assert-msg-test.py +++ b/glib/tests/assert-msg-test.py @@ -78,7 +78,12 @@ class TestAssertMessage(unittest.TestCase): env = os.environ.copy() env["LC_ALL"] = "C.UTF-8" - print("Environment:", env) + try: + print("Environment:", env) + except UnicodeEncodeError: + # Can happen if the environment contains non-ASCII bytes but the + # environment we’re running in wants output in a different locale. + pass # We want to ensure consistent line endings... info = subprocess.run( @@ -108,7 +113,12 @@ class TestAssertMessage(unittest.TestCase): env = os.environ.copy() env["LC_ALL"] = "C.UTF-8" - print("Environment:", env) + try: + print("Environment:", env) + except UnicodeEncodeError: + # Can happen if the environment contains non-ASCII bytes but the + # environment we’re running in wants output in a different locale. + pass # We want to ensure consistent line endings... info = subprocess.run( diff --git a/glib/tests/messages-low-memory.py b/glib/tests/messages-low-memory.py index 8e071b16478c4d4d04460ed786d0a088331ceafb..26f01275d94a8e80d16f19e12d4dc9782894ab64 100644 --- a/glib/tests/messages-low-memory.py +++ b/glib/tests/messages-low-memory.py @@ -63,7 +63,12 @@ class TestMessagesLowMemory(unittest.TestCase): env = os.environ.copy() env["LC_ALL"] = "C.UTF-8" - print("Environment:", env) + try: + print("Environment:", env) + except UnicodeEncodeError: + # Can happen if the environment contains non-ASCII bytes but the + # environment we’re running in wants output in a different locale. + pass # We want to ensure consistent line endings... info = subprocess.run( diff --git a/gobject/tests/genmarshal.py b/gobject/tests/genmarshal.py index 1062dfe625c1fa34e294f096aa6fac20bfc5a660..68b074c5d1943c1da740468677b8732f40e0ddae 100644 --- a/gobject/tests/genmarshal.py +++ b/gobject/tests/genmarshal.py @@ -88,7 +88,12 @@ class TestGenmarshal(unittest.TestCase): env = os.environ.copy() env["LC_ALL"] = "C.UTF-8" - print("Environment:", env) + try: + print("Environment:", env) + except UnicodeEncodeError: + # Can happen if the environment contains non-ASCII bytes but the + # environment we’re running in wants output in a different locale. + pass # We want to ensure consistent line endings... info = subprocess.run( diff --git a/gobject/tests/gobject-query.py b/gobject/tests/gobject-query.py index 618b6bae910b36811e0db5ca2bdd10b00642794f..e69f1c79dc92ff0891a0b75b9dfcf29bfd40d1d5 100644 --- a/gobject/tests/gobject-query.py +++ b/gobject/tests/gobject-query.py @@ -59,7 +59,12 @@ class TestGobjectQuery(unittest.TestCase): env = os.environ.copy() env["LC_ALL"] = "C.UTF-8" - print("Environment:", env) + try: + print("Environment:", env) + except UnicodeEncodeError: + # Can happen if the environment contains non-ASCII bytes but the + # environment we’re running in wants output in a different locale. + pass # We want to ensure consistent line endings... info = subprocess.run( diff --git a/gobject/tests/mkenums.py b/gobject/tests/mkenums.py index b58d23e799335cb6722756de96a705c14e739094..0e0b13f49866f888f2ad60abb09e5030b8fc8c66 100644 --- a/gobject/tests/mkenums.py +++ b/gobject/tests/mkenums.py @@ -100,7 +100,12 @@ class TestMkenums(unittest.TestCase): env = os.environ.copy() env["LC_ALL"] = "C.UTF-8" - print("Environment:", env) + try: + print("Environment:", env) + except UnicodeEncodeError: + # Can happen if the environment contains non-ASCII bytes but the + # environment we’re running in wants output in a different locale. + pass # We want to ensure consistent line endings... info = subprocess.run( diff --git a/gobject/tests/taptestrunner.py b/gobject/tests/taptestrunner.py index 9adbd8daa4641dd081b40547d4ce3b0b09c0b0a0..b7ed99870914172655946464dac093d9e82c3ef7 100644 --- a/gobject/tests/taptestrunner.py +++ b/gobject/tests/taptestrunner.py @@ -68,6 +68,9 @@ class TAPTestResult(unittest.TestResult): else: self.test_output = StringIO() + self.message.encoding = sys.stdout.encoding + self.test_output.encoding = sys.stdout.encoding + if self.message_log == self.test_output_log: self.test_output = self.message sys.stdout = sys.stderr = self.test_output