diff options
author | Guido Günther <agx@sigxcpu.org> | 2017-11-06 19:22:03 +0100 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2017-11-06 19:24:08 +0100 |
commit | e972bc97a47a57359fc6793f61e0022fd123b5d5 (patch) | |
tree | 7c46ad89c872c863e91e20dca5ea9ebf705b11b8 /tests | |
parent | b1a03534a0bde38a21c844302eff1a0a0bd2e863 (diff) |
tests: use encoding when opening files for checks and fixtures
so we don't fail on non utf-8 locales
Diffstat (limited to 'tests')
-rw-r--r-- | tests/11_test_dch_main.py | 2 | ||||
-rw-r--r-- | tests/component/__init__.py | 2 | ||||
-rw-r--r-- | tests/component/deb/test_dch.py | 2 | ||||
-rw-r--r-- | tests/doctests/test_Changelog.py | 4 | ||||
-rw-r--r-- | tests/testutils/__init__.py | 2 |
5 files changed, 6 insertions, 6 deletions
diff --git a/tests/11_test_dch_main.py b/tests/11_test_dch_main.py index 58b0eb94..f0f4560e 100644 --- a/tests/11_test_dch_main.py +++ b/tests/11_test_dch_main.py @@ -82,7 +82,7 @@ class TestScriptDch(DebianGitTestRepo): ret = dch.main(options) self.assertEqual(ret, 0) cl = os.path.join(self.repo.path, 'debian/changelog') - return open(cl).readlines() + return open(cl, encoding='utf-8').readlines() def test_dch_main_new_upstream_version(self): """Test dch.py like gbp dch script does: new upstream version""" diff --git a/tests/component/__init__.py b/tests/component/__init__.py index 7f9c7ff9..0dbbd95e 100644 --- a/tests/component/__init__.py +++ b/tests/component/__init__.py @@ -227,7 +227,7 @@ class ComponentTestBase(unittest.TestCase, GbpLogTester): This assumes the hook was set too printenv > hookname.out """ - with open('%s.out' % name) as f: + with open('%s.out' % name, encoding='utf-8') as f: parsed = dict([line[:-1].split('=', 1) for line in f.readlines() if line.startswith("GBP_")]) for var in expected: diff --git a/tests/component/deb/test_dch.py b/tests/component/deb/test_dch.py index 053597e6..3d969b14 100644 --- a/tests/component/deb/test_dch.py +++ b/tests/component/deb/test_dch.py @@ -57,7 +57,7 @@ class TestDch(ComponentTestBase): repo.commit_all(msg="test customizations") ok_(dch(['arg0', '-S', '-a', '--customizations=customizations.py']) == 0, "dch did no succeed as expected") - with open("debian/changelog") as f: + with open("debian/changelog", encoding='utf-8') as f: cl = f.read() ok_('* testentry\n' in cl) del gbp.scripts.dch.user_customizations['format_changelog_entry'] diff --git a/tests/doctests/test_Changelog.py b/tests/doctests/test_Changelog.py index 3e64f4d2..af7d40dd 100644 --- a/tests/doctests/test_Changelog.py +++ b/tests/doctests/test_Changelog.py @@ -263,7 +263,7 @@ def test_add_section(): >>> testdebdir = os.path.join(testdir, 'debian') >>> testclname = os.path.join(testdebdir, "changelog") >>> os.mkdir(testdebdir) - >>> clh = open(os.path.join(testdebdir, "changelog"), "w") + >>> clh = open(os.path.join(testdebdir, "changelog"), "w", encoding='utf-8') >>> ret = clh.write(cl_debian) >>> clh.close() >>> os.chdir(testdir) @@ -310,7 +310,7 @@ def test_add_entry(): >>> testdebdir = os.path.join(testdir, 'debian') >>> testclname = os.path.join(testdebdir, "changelog") >>> os.mkdir(testdebdir) - >>> clh = open(os.path.join(testdebdir, "changelog"), "w") + >>> clh = open(os.path.join(testdebdir, "changelog"), "w", encoding='utf-8') >>> ret = clh.write(cl_debian) >>> clh.close() >>> os.chdir(testdir) diff --git a/tests/testutils/__init__.py b/tests/testutils/__init__.py index febd9e2b..c17bc815 100644 --- a/tests/testutils/__init__.py +++ b/tests/testutils/__init__.py @@ -85,7 +85,7 @@ def get_dch_default_urgency(): pass else: if ret == 0: - with open(tmp_dch_name) as dchfile: + with open(tmp_dch_name, encoding='utf-8') as dchfile: header = dchfile.readline().strip() urgency = header.split()[-1].replace('urgency=', '') finally: |