Skip to content

Commit 59d7666

Browse files
committed
add test to check whether easyconfig that includes unicode character in description doesn't trigger UnicodeDecodeError (cfr. #3284)
1 parent 52af67d commit 59d7666

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

test/framework/toy_build.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# #
1+
# -*- coding: utf-8 -*-
2+
##
23
# Copyright 2013-2020 Ghent University
34
#
45
# This file is part of EasyBuild,
@@ -2606,6 +2607,26 @@ def __exit__(self, type, value, traceback):
26062607
self.assertErrorRegex(EasyBuildError, error_pattern, self.test_toy_build,
26072608
extra_args=extra_args, raise_error=True, verbose=False)
26082609

2610+
def test_toy_build_unicode_description(self):
2611+
"""Test installation of easyconfig file that has non-ASCII characters in description."""
2612+
# cfr. https://github.com/easybuilders/easybuild-framework/issues/3284
2613+
2614+
test_ecs_dir = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'easyconfigs', 'test_ecs')
2615+
toy_ec = os.path.join(test_ecs_dir, 't', 'toy', 'toy-0.0.eb')
2616+
toy_ec_txt = read_file(toy_ec)
2617+
2618+
# the tilde character included here is a Unicode tilde character, not a regular ASCII tilde (~)
2619+
descr = "This description includes a unicode tilde character: ∼, for your entertainment."
2620+
self.assertFalse('~' in descr)
2621+
2622+
regex = re.compile(r'^description\s*=.*', re.M)
2623+
test_ec_txt = regex.sub(r'description = "%s"' % descr, toy_ec_txt)
2624+
2625+
test_ec = os.path.join(self.test_prefix, 'test.eb')
2626+
write_file(test_ec, test_ec_txt)
2627+
2628+
self.test_toy_build(ec_file=test_ec, raise_error=True)
2629+
26092630

26102631
def suite():
26112632
""" return all the tests in this file """

0 commit comments

Comments
 (0)