From: Bruno Haible Date: Thu, 17 Oct 2024 23:16:12 +0000 (+0200) Subject: xgettext: Python: Add test for warning that was broken in 0.21.x and 0.22.x. X-Git-Tag: v0.23~45 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c31a5e4e90cb52c0b168f3cab9ac7f94c87df945;p=thirdparty%2Fgettext.git xgettext: Python: Add test for warning that was broken in 0.21.x and 0.22.x. Reported by Max Smolens in . * gettext-tools/tests/xgettext-python-9: New file. * gettext-tools/tests/Makefile.am (TESTS): Add it. --- diff --git a/gettext-tools/tests/Makefile.am b/gettext-tools/tests/Makefile.am index ae4efd9ff..602a18081 100644 --- a/gettext-tools/tests/Makefile.am +++ b/gettext-tools/tests/Makefile.am @@ -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 index 000000000..40a794aee --- /dev/null +++ b/gettext-tools/tests/xgettext-python-9 @@ -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