Merge branch 'merge-no-commit'
[git-cola.git] / test / cmds_test.py
blob9b611438c0b9fdc2944469263c5afeba7cca5782
1 #!/usr/bin/env python
2 # -*- encoding: utf-8 -*-
3 from __future__ import unicode_literals
4 import unittest
7 from cola import cmds
8 from cola.compat import unichr
11 class CmdsTestCase(unittest.TestCase):
12 """Tests the cola.core module's unicode handling
13 """
15 def test_Commit_strip_comments(self):
16 """Ensure that commit messages are stripped of comments"""
18 msg = 'subject\n\n#comment\nbody'
19 expect = 'subject\n\nbody\n'
20 actual = cmds.Commit.strip_comments(msg)
21 self.assertEqual(expect, actual)
23 def test_Commit_strip_comments_unicode(self):
24 """Ensure that unicode is preserved in stripped commit messages"""
26 msg = unichr(0x1234) + '\n\n#comment\nbody'
27 expect = unichr(0x1234) + '\n\nbody\n'
28 actual = cmds.Commit.strip_comments(msg)
29 self.assertEqual(expect, actual)
31 def test_unix_path_win32(self):
32 path = r'Z:\Program Files\git-cola\bin\git-dag'
33 expect = '/Z/Program Files/git-cola/bin/git-dag'
34 actual = cmds.unix_path(path, is_win32=lambda: True)
35 self.assertEqual(expect, actual)
37 def test_unix_path_is_a_noop_on_sane_platforms(self):
38 path = r'/:we/don\t/need/no/stinking/badgers!'
39 expect = path
40 actual = cmds.unix_path(path, is_win32=lambda: False)
41 self.assertEqual(expect, actual)
44 if __name__ == '__main__':
45 unittest.main()