Merge ~ines-almeida/launchpad:force-tests-container-locale into launchpad:master

Proposed by Ines Almeida
Status: Merged
Approved by: Ines Almeida
Approved revision: 55bbfa804a55184c6a095109928c78d6721e3b35
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~ines-almeida/launchpad:force-tests-container-locale
Merge into: launchpad:master
Diff against target: 22 lines (+4/-0)
1 file modified
lib/lp/scripts/utilities/test.py (+4/-0)
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+440031@code.launchpad.net

Commit message

Force test container locale

This prevents local setups from influencing test results regarding locale setup.

Description of the change

Added a quick locale setup in the environment configuration in `lp/scripts/utilities/test`

Tested it locally in tests that were failing, and it "fixed" the issue

To post a comment you must log in.
Revision history for this message
Ines Almeida (ines-almeida) wrote :

FYI, had a look into using `os.environ` but for that we would need to change all locale variables, this seemed much cleaner.

Revision history for this message
Ines Almeida (ines-almeida) wrote :

Is this tiny change worth a test to check the locale, or is all tests passing enough testing?

Revision history for this message
Colin Watson (cjwatson) wrote :

LGTM, thanks. I don't think we need a separate test for this.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/scripts/utilities/test.py b/lib/lp/scripts/utilities/test.py
2index d997a8a..93d16cf 100755
3--- a/lib/lp/scripts/utilities/test.py
4+++ b/lib/lp/scripts/utilities/test.py
5@@ -15,6 +15,7 @@
6
7 import argparse
8 import doctest
9+import locale
10 import os
11 import random
12 import re
13@@ -52,6 +53,9 @@ def configure_environment():
14 os.environ["TZ"] = "Asia/Calcutta"
15 time.tzset()
16
17+ # Forces tests to run with a sensible locale encoding
18+ locale.setlocale(locale.LC_ALL, "C.UTF-8")
19+
20 # Httplib2 0.7 started validating SSL certificates, and the test suite
21 # uses a self-signed certificate, so disable it with an env variable.
22 os.environ["LP_DISABLE_SSL_CERTIFICATE_VALIDATION"] = "1"

Subscribers

People subscribed via source and target branches

to status/vote changes: