From 7e913145a38c713123a6eda73ac16b757d5ed1df Mon Sep 17 00:00:00 2001 From: Gregory Haynes Date: Thu, 9 Oct 2014 00:01:41 -0700 Subject: [PATCH] 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 Change-Id: I45cdf7d921fbca5f09e5f65bd69fcee83fb7c8e4 --- os_collect_config/tests/test_collect.py | 6 ++++-- os_collect_config/tests/test_local.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/os_collect_config/tests/test_collect.py b/os_collect_config/tests/test_collect.py index e46a59e..5cbabfb 100644 --- a/os_collect_config/tests/test_collect.py +++ b/os_collect_config/tests/test_collect.py @@ -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: diff --git a/os_collect_config/tests/test_local.py b/os_collect_config/tests/test_local.py index 22f5d16..0e0f011 100644 --- a/os_collect_config/tests/test_local.py +++ b/os_collect_config/tests/test_local.py @@ -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)