svn commit: r1926510 - in /subversion/branches/utf8-cmdline-prototype/subversion/tests/cmdline: basic_tests.py svntest/testcase.py

[email protected]
Newsgroups gmane.comp.version-control.subversion.svn
Message-ID <[email protected]>
Author: rinrab
Date: Tue Jun 17 18:31:22 2025
New Revision: 1926510

URL: http://svn.apache.org/viewvc?rev=1926510&view=rev
Log:
On the 'utf8-cmdline-prototype' branch: Add RequireUtf8 decorator and
run the basic_tests#unicode_arguments_test test in UTF8 environment to fix
failure its constant failures on Unix platforms.

* subversion/tests/cmdline/basic_tests.py
  (): Import RequireUtf8 decorator from testcase.py
  (unicode_arguments_test): Require UTF-8.
* subversion/tests/cmdline/svntest/testcase.py
  (_detect_utf8_locale): New local helper.
  (RequireUtf8_deco): Declare the decorator.

Patch by: jun66j5

PS: Sorry for committing this on my own, but I think you left it up to
me. Am I right? 😁

Modified:
    subversion/branches/utf8-cmdline-prototype/subversion/tests/cmdline/basic_tests.py
    subversion/branches/utf8-cmdline-prototype/subversion/tests/cmdline/svntest/testcase.py

Modified: subversion/branches/utf8-cmdline-prototype/subversion/tests/cmdline/basic_tests.py
URL: http://svn.apache.org/viewvc/subversion/branches/utf8-cmdline-prototype/subversion/tests/cmdline/basic_tests.py?rev=1926510&r1=1926509&r2=1926510&view=diff
==============================================================================
--- subversion/branches/utf8-cmdline-prototype/subversion/tests/cmdline/basic_tests.py (original)
+++ subversion/branches/utf8-cmdline-prototype/subversion/tests/cmdline/basic_tests.py Tue Jun 17 18:31:22 2025
@@ -40,6 +40,7 @@ XFail = svntest.testcase.XFail_deco
 Issues = svntest.testcase.Issues_deco
 Issue = svntest.testcase.Issue_deco
 Wimp = svntest.testcase.Wimp_deco
+RequireUtf8 = svntest.testcase.RequireUtf8_deco
 Item = wc.StateItem
 
 # Generic UUID-matching regular expression
@@ -3346,6 +3347,7 @@ def argv_with_best_fit_chars(sbox):
   if count == 0:
     raise svntest.Skip('No best fit characters in code page %r' % codepage)
 
+@RequireUtf8
 def unicode_arguments_test(sbox: svntest.sandbox.Sandbox):
   """test unicode arguments"""
 

Modified: subversion/branches/utf8-cmdline-prototype/subversion/tests/cmdline/svntest/testcase.py
URL: http://svn.apache.org/viewvc/subversion/branches/utf8-cmdline-prototype/subversion/tests/cmdline/svntest/testcase.py?rev=1926510&r1=1926509&r2=1926510&view=diff
==============================================================================
--- subversion/branches/utf8-cmdline-prototype/subversion/tests/cmdline/svntest/testcase.py (original)
+++ subversion/branches/utf8-cmdline-prototype/subversion/tests/cmdline/svntest/testcase.py Tue Jun 17 18:31:22 2025
@@ -349,3 +349,50 @@ def SkipDumpLoadCrossCheck_deco(cond_fun
 
 # Create a singular alias, for linguistic correctness
 Issue_deco = Issues_deco
+
+
+# Determines the name of UTF-8 locale on the system, or returns None if one
+# couldn't be found.
+def _detect_utf8_locale():
+    import locale
+
+    orig = None
+    try:
+        for name in ('C.UTF-8', 'en_US.UTF-8'):
+            try:
+                orig = locale.setlocale(locale.LC_ALL, name)
+            except locale.Error:
+                continue
+            else:
+                return name
+    finally:
+        if orig is not None:
+            locale.setlocale(locale.LC_ALL, orig)
+
+    return None  # utf-8 locale unavailable
+
+_utf8_locale = _detect_utf8_locale() if os.name != 'nt' else False
+
+# Decorator that runs the test in UTF-8 environment. If there are no good
+# UTF-8 locales availible on the system, skips the test.
+def RequireUtf8_deco(f):
+
+    import functools
+
+    @functools.wraps(f)
+    def wrapper(sbox: svntest.sandbox.Sandbox):
+        if _utf8_locale is None:
+            raise svntest.Skip
+        if _utf8_locale is not False:
+            orig = os.environ.get('LC_ALL')
+            os.environ['LC_ALL'] = _utf8_locale
+        try:
+            return f(sbox)
+        finally:
+            if _utf8_locale is not False:
+                if orig is None:
+                    del os.environ['LC_ALL']
+                else:
+                    os.environ['LC_ALL'] = orig
+
+    return wrapper
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.