Fix py3k popen and locale test fails

A popen call is made in the Python 3 platform module which causes our
assertions for our mock'd popen to fail. Also fixing a locale issue to
use defaultlocale() rather than LC_ALL.

Co-Authored-By: Steve Kowalik <steven@wedontsleep.org>
Change-Id: I45cdf7d921fbca5f09e5f65bd69fcee83fb7c8e4
This commit is contained in:
Gregory Haynes 2014-10-09 00:01:41 -07:00
parent 0f83ecbc2f
commit 7e913145a3
2 changed files with 5 additions and 3 deletions

View File

@ -119,8 +119,10 @@ class TestCollect(testtools.TestCase):
'server'
]
calls = self._fake_popen_call_main(occ_args)
proc_args = calls[0]
self.assertEqual(expected_cmd, proc_args['args'])
# The Python 3 platform module makes a popen call, filter this out
proc_calls = [call for call in calls if call['args'] == expected_cmd]
self.assertEqual(len(proc_calls), 1)
proc_args = proc_calls[0]
for test_dir in (cache_dir, backup_cache_dir):
list_path = os.path.join(test_dir.path, 'os_config_files.json')
with open(list_path) as list_file:

View File

@ -114,7 +114,7 @@ class TestLocal(testtools.TestCase):
def wrong_sort_listdir(path):
ret = unpatched_listdir(path)
save_locale = locale.getlocale(locale.LC_ALL)
save_locale = locale.getdefaultlocale()
locale.setlocale(locale.LC_ALL, 'C')
bad_sort = sorted(ret, reverse=True)
locale.setlocale(locale.LC_ALL, save_locale)