Reworked the local_libpath() using the code form _import_local_thrift

- Common problem, common code
diff --git a/test/py/util.py b/test/py/util.py
index 31e8475..d7e2fa3 100644
--- a/test/py/util.py
+++ b/test/py/util.py
@@ -26,14 +26,9 @@
 
 
 def local_libpath():
-    globdir = os.path.join(_ROOT_DIR, 'lib', 'py', 'build', 'lib.*')
-    # Consider MM.mm and MMmm as valid local lib paths.
-    # On Windows 11 with Python 3.13.9 the second option is required
-    version_formats = [
-        '-%d.%d' % (sys.version_info[0], sys.version_info[1]),
-        '-%d%d' % (sys.version_info[0], sys.version_info[1])
-    ]
-    for libpath in glob.glob(globdir):
-        for fmt in version_formats:
-            if libpath.endswith(fmt):
-                return libpath
\ No newline at end of file
+    # Handle MM.mm and MMmm -> Code copied from _import_local_thrift and adapted
+    for libpath in glob.glob(os.path.join(_ROOT_DIR, 'lib', 'py', 'build', 'lib.*')):
+        for pattern in ('-%d.%d', '-%d%d'):
+            postfix = pattern % (sys.version_info[0], sys.version_info[1])
+            if libpath.endswith(postfix):
+                return libpath