Mercurial > python-hglib
diff tests/test_heads.py @ 225:fba806958dba
tests: add regression test to check for null byte handling
author | Mathias De Mare <mathias.de_mare@nokia.com> |
---|---|
date | Tue, 14 Mar 2023 14:35:58 +0100 |
parents | a2afbf236ca8 |
children |
line wrap: on
line diff
--- a/tests/test_heads.py Mon Mar 13 15:32:20 2023 +0100 +++ b/tests/test_heads.py Tue Mar 14 14:35:58 2023 +0100 @@ -1,5 +1,6 @@ from tests import common from hglib.util import b +import subprocess class test_heads(common.basetest): def test_empty(self): @@ -15,3 +16,14 @@ rev, node1 = self.client.commit(b('second')) self.assertEqual(self.client.heads(node0, topological=True), []) + + def test_null_byte(self): + self.append('a', 'a') + with open('commitmessagenullbyte', 'w') as f: + f.write('some message\0more stuff') + # use 'hg' directly here as hglib doesn't allow + # committing null byte descriptions + subprocess.check_call(["hg", "commit", + "-l", "commitmessagenullbyte", "--addremove", "-q"]) + revs = self.client.heads() + self.assertEqual(revs[0].desc, b('some message\0more stuff'))