#1260 use LANG=C for running all tests
Merged 5 years ago by mikem. Opened 6 years ago by tkopecek.
tkopecek/koji issue1259  into  master

@@ -1,5 +1,6 @@ 

  from __future__ import absolute_import

  import json

+ import locale

  import mock

  import os

  import tempfile
@@ -72,6 +73,8 @@ 

          mock.patch.stopall()

  

      def test_build_notification(self):

+         # force locale to compare 'message' value

+         locale.setlocale(locale.LC_ALL, ('en_US', 'UTF-8'))

          # task_info['id'], method, params, self.session, self.options

          task_id = 999

          fn = os.path.join(os.path.dirname(__file__), 'data/calls', 'build_notif_1', 'params.json')
@@ -102,3 +105,5 @@ 

          with open(fn, 'rb') as fp:

              msg_expect = fp.read().decode()

          self.assertEqual(message, msg_expect)

+ 

+         locale.resetlocale()

file modified
+4
@@ -1,5 +1,6 @@ 

  from __future__ import print_function

  from __future__ import absolute_import

+ import locale

  import mock

  import os

  import six
@@ -198,6 +199,9 @@ 

  

      @mock.patch('koji_cli.commands.activate_session')

      def assert_help(self, callableObj, message, activate_session_mock):

+         # optarse uses gettext directly and it is driven by LANGUAGE

+         # we need engligsh to get comparable strings

+         os.environ['LANGUAGE'] = 'en_GB'

          self.assert_system_exit(

              callableObj,

              mock.MagicMock(),

@@ -1,5 +1,6 @@ 

  from __future__ import absolute_import

  import datetime

+ import locale

  try:

      import unittest2 as unittest

  except ImportError:
@@ -30,6 +31,9 @@ 

          self.assertEqual(formatTime(desired + '.123'), desired)

  

      def test_format_time_long(self):

+         # force locale to compare 'desired' value

+         locale.setlocale(locale.LC_ALL, ('en_US', 'UTF-8'))

+ 

          self.assertEqual(formatTimeLong(None), '')

          self.assertEqual(formatTimeLong(''), '')

  
@@ -57,3 +61,5 @@ 

          r = formatTimeLong(d2 + '.123')

          r = r[:r.rfind(' ')]

          self.assertEqual(r, desired)

+ 

+         locale.resetlocale()

@@ -1,6 +1,7 @@ 

  # coding=utf-8

  from __future__ import absolute_import

  import calendar

+ import locale

  import mock

  import optparse

  import os
@@ -551,6 +552,8 @@ 

  

      def test_formatChangelog(self):

          """Test formatChangelog function"""

+         # force locale to compare 'expect' value

+         locale.setlocale(locale.LC_ALL, ('en_US', 'UTF-8'))

          data = [

                  {

                      'author': 'Happy Koji User <user1@example.com> - 1.1-1',
@@ -585,6 +588,8 @@ 

          result = koji.util.formatChangelog(data)

          self.assertMultiLineEqual(expect, result)

  

+         locale.resetlocale()

+ 

      def test_parseTime(self):

          """Test parseTime function"""

          now = datetime.now()

Please use C.UTF-8. Otherwise things will break in very odd ways...

Please use C.UTF-8. Otherwise things will break in very odd ways...

It worked only in combo with LANGUAGE=C.UTF-8 - otherwise I've got fixed external commands output, but not descriptions in python's exceptions (OSError)

rebased onto d03dda9

6 years ago

rebased onto 91068f8d319bf659fa0f968d3ce4716c32fe7e07

6 years ago

@tkopecek You can use LC_ALL in place of LANGUAGE and LANG, I think?

Nope, LC_ALL doesn't override LANGUAGE (tested).

rebased onto b07404d72b36178c5ba9c7c7ab07dc91bd87a284

5 years ago

rebased onto 498c43326ea764936f38e359e350a0cdd8acdcd3

5 years ago

I've used (rebase+change) more local approach, so we can catch some other errors.

rebased onto 739e9d0

5 years ago

...and used en_US.UTF-8 as RHEL6/7 doesn't like C.UTF-8 :-(

Commit 9046479 fixes this pull-request

Pull-Request has been merged by mikem

5 years ago