]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
xgettext: Python: Add test for warning that was broken in 0.21.x and 0.22.x.
authorBruno Haible <bruno@clisp.org>
Thu, 17 Oct 2024 23:16:12 +0000 (01:16 +0200)
committerBruno Haible <bruno@clisp.org>
Thu, 17 Oct 2024 23:16:12 +0000 (01:16 +0200)
Reported by Max Smolens <msmolens@gmail.com> in
<https://lists.gnu.org/archive/html/bug-gettext/2020-10/msg00001.html>.

* gettext-tools/tests/xgettext-python-9: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add it.

gettext-tools/tests/Makefile.am
gettext-tools/tests/xgettext-python-9 [new file with mode: 0755]

index ae4efd9ff562d29f72e9ac5bb4644f1d9c4ca0da..602a18081261869e9a0c39d3263ca3d907e2419e 100644 (file)
@@ -153,7 +153,7 @@ TESTS = gettext-1 gettext-2 \
        xgettext-rst-1 xgettext-rst-2 \
        xgettext-python-1 xgettext-python-2 xgettext-python-3 \
        xgettext-python-4 xgettext-python-5 xgettext-python-6 \
-       xgettext-python-7 xgettext-python-8 \
+       xgettext-python-7 xgettext-python-8 xgettext-python-9 \
        xgettext-python-stackovfl-1 xgettext-python-stackovfl-2 \
        xgettext-python-stackovfl-3 xgettext-python-stackovfl-4 \
        xgettext-ruby-1 xgettext-ruby-2 \
diff --git a/gettext-tools/tests/xgettext-python-9 b/gettext-tools/tests/xgettext-python-9
new file mode 100755 (executable)
index 0000000..40a794a
--- /dev/null
@@ -0,0 +1,25 @@
+#!/bin/sh
+. "${srcdir=.}/init.sh"; path_prepend_ . ../src
+
+# Test Python support:
+# warning "format string with unnamed arguments cannot be properly localized"
+
+cat <<\EOF > xg-py-9-1.py
+gettext ("foo %s bar") % ('a');
+EOF
+
+: ${XGETTEXT=xgettext}
+${XGETTEXT} --omit-header --no-location -d xg-py-9-1 xg-py-9-1.py 2>xg-py-9-1.err || Exit 1
+# Expect no warning here (because the format string has only one placeholder).
+if test -s xg-py-9-1.err; then
+  Exit 1
+fi
+
+cat <<\EOF > xg-py-9-2.py
+gettext ("foo %s and %s bar") % ('a', 'b');
+EOF
+
+: ${XGETTEXT=xgettext}
+${XGETTEXT} --omit-header --no-location -d xg-py-9-2 xg-py-9-2.py 2>xg-py-9-2.err || Exit 1
+# Expect a warning here (because the format string has two placeholders).
+test -s xg-py-9-2.err || Exit 1