# HG changeset patch # User Manuel Jacob # Date 2020-03-05 17:10:19 # Node ID 109322cd322a708200d5d191ebce9f01f2582961 # Parent 336ec75ed1ac61e029ecb0d129539053dbc8ddec tests: avoid implicit conversion of str to unicode On Python 2, str.encode('ascii') implicitly converts the string to unicode and then back to str. Since the point of this expression is to convert a bool to a str, the '%r' conversion specifier can be used instead in the format string. diff --git a/tests/run-tests.py b/tests/run-tests.py --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -1428,7 +1428,7 @@ class Test(unittest.TestCase): ) hgrc.write(b'[web]\n') hgrc.write(b'address = localhost\n') - hgrc.write(b'ipv6 = %s\n' % str(self._useipv6).encode('ascii')) + hgrc.write(b'ipv6 = %r\n' % self._useipv6) hgrc.write(b'server-header = testing stub value\n') for opt in self._extraconfigopts: