use LANG=C for running tests comparing human-readable output
This commit is contained in:
parent
a1be473a6e
commit
6fd33bfd1f
4 changed files with 20 additions and 0 deletions
|
|
@ -1,5 +1,6 @@
|
|||
from __future__ import absolute_import
|
||||
import json
|
||||
import locale
|
||||
import mock
|
||||
import os
|
||||
import tempfile
|
||||
|
|
@ -72,6 +73,8 @@ class TestBuildNotification(unittest.TestCase):
|
|||
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 @@ class TestBuildNotification(unittest.TestCase):
|
|||
with open(fn, 'rb') as fp:
|
||||
msg_expect = fp.read().decode()
|
||||
self.assertEqual(message, msg_expect)
|
||||
|
||||
locale.resetlocale()
|
||||
|
|
|
|||
|
|
@ -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 @@ class CliTestCase(unittest.TestCase):
|
|||
|
||||
@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 @@ class TestFormatTime(unittest.TestCase):
|
|||
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 @@ class TestFormatTime(unittest.TestCase):
|
|||
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 @@ class MavenUtilTestCase(unittest.TestCase):
|
|||
|
||||
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 @@ class MavenUtilTestCase(unittest.TestCase):
|
|||
result = koji.util.formatChangelog(data)
|
||||
self.assertMultiLineEqual(expect, result)
|
||||
|
||||
locale.resetlocale()
|
||||
|
||||
def test_parseTime(self):
|
||||
"""Test parseTime function"""
|
||||
now = datetime.now()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue