commit:     a7ee4cda4858f179540c396ce79bc9b3dfc95f3d
Author:     Marek Szuba <marecki <AT> gentoo <DOT> org>
AuthorDate: Sat May 15 14:10:54 2021 +0000
Commit:     Marek Szuba <marecki <AT> gentoo <DOT> org>
CommitDate: Sat May 15 14:22:01 2021 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a7ee4cda

app-misc/gramps: tests: do not rely on presence of en_US.UTF-8 locale

Signed-off-by: Marek Szuba <marecki <AT> gentoo.org>

 .../gramps/files/gramps-5.1.3-test_locale.patch    | 30 ++++++++++++++++++++++
 app-misc/gramps/gramps-5.1.3.ebuild                | 16 +++++++++---
 2 files changed, 42 insertions(+), 4 deletions(-)

diff --git a/app-misc/gramps/files/gramps-5.1.3-test_locale.patch 
b/app-misc/gramps/files/gramps-5.1.3-test_locale.patch
new file mode 100644
index 00000000000..40eba66dd21
--- /dev/null
+++ b/app-misc/gramps/files/gramps-5.1.3-test_locale.patch
@@ -0,0 +1,30 @@
+GEDCOM-import tests explicitly set the locale to en_US.UTF8 because they
+assume a US date and time format. That locale is not guaranteed to be
+present and checking that in ebuild is a hassle, therefore use C.UTF8
+instead - it's similar enough.
+
+--- a/data/tests/imp_sample.gramps
++++ b/data/tests/imp_sample.gramps
+@@ -1706,7 +1706,7 @@
+       </style>
+     </note>
+     <note handle="_000000f9000000f9" change="1591544255" id="N0036" 
type="General">
+-      <text>Objects referenced by this note were missing in a file imported 
on 12/25/1999 12:00:00 AM.</text>
++      <text>Objects referenced by this note were missing in a file imported 
on 12/25/99 00:00:00.</text>
+     </note>
+   </notes>
+ </database>
+--- a/gramps/plugins/test/imports_test.py
++++ b/gramps/plugins/test/imports_test.py
+@@ -51,10 +51,7 @@
+ # ------------------------------------------------------------------
+ 
+ # These tests assume a US date and time format.
+-try:
+-    locale.setlocale(locale.LC_ALL, 'en_US.utf8')
+-except locale.Error:     # seems to fail on Windows system for some reason
+-    locale.setlocale(locale.LC_ALL, 'English_United States')
++locale.setlocale(locale.LC_ALL, 'C.utf8')
+ 
+ 
+ def mock_time(*args):

diff --git a/app-misc/gramps/gramps-5.1.3.ebuild 
b/app-misc/gramps/gramps-5.1.3.ebuild
index 9908893b3c3..0c5ddbf8781 100644
--- a/app-misc/gramps/gramps-5.1.3.ebuild
+++ b/app-misc/gramps/gramps-5.1.3.ebuild
@@ -44,6 +44,10 @@ BDEPEND="test? ( ${RDEPEND}
        ')
 )"
 
+PATCHES=(
+       "${FILESDIR}"/${PN}-5.1.3-test_locale.patch
+)
+
 python_prepare_all() {
        # Install documentation to the proper location. This can't be done
        # easily with a patch because we substitute in the ${PF} variable,
@@ -67,10 +71,14 @@ python_test_all() {
        rm -rf "${S}/build" && ln -s "${BUILD_DIR}" "${S}"/build || \
                die "Failed to symlink build directory to source directory"
 
-       # FIXME: some of the tests fail if the locale 'en_US.UTF-8' is absent,
-       # at least as of 5.1.2 this failure does not propagate back to this
-       # function but we should still handle this properly somehow.
-       esetup.py test
+       # Set a sane default locale for the tests which do not explicitly set 
one.
+       local -x LC_ALL=C.UTF-8
+
+       # Note that as of 5.1.3, test failures do not actually propagate back
+       # to this function. For now this is fortunate because the test suite
+       # does not handle the absence of bsddb3 well, in the long run however
+       # this should be fixed.
+       esetup.py test || die
 }
 
 # Ugly hack to work around Bug #717922

Reply via email to