logging: add back support for GTKDOC_TRACE
[gtk-doc.git] / tests / gtkdoc-common.py
blob6f5969a20ac5df2a6d48dd10b24be13e54fb19ba
1 #!/usr/bin/env python
3 import mock
4 import unittest
6 from gtkdoc import common
9 class TestUpdateFileIfChanged(unittest.TestCase):
11 @mock.patch('os.path.exists')
12 @mock.patch('os.rename')
13 def test_NoOldFile(self, os_rename, os_path_exists):
14 os_path_exists.return_value = False
15 res = common.UpdateFileIfChanged('/foo', '/bar', False)
16 os_rename.assert_called_with('/bar', '/foo')
17 self.assertTrue(res)
20 class TestGetModuleDocDir(unittest.TestCase):
22 @mock.patch('subprocess.check_output')
23 def test_ReturnsPath(self, subprocess_check_output):
24 subprocess_check_output.return_value = '/usr'
25 self.assertEquals(common.GetModuleDocDir('glib-2.0'), '/usr/share/gtk-doc/html')
28 class TestCreateValidSGMLID(unittest.TestCase):
30 def test_AlreadyValid(self):
31 self.assertEquals(common.CreateValidSGMLID('x'), 'x')
33 def test_SpecialCharsBecomeDash(self):
34 self.assertEquals(common.CreateValidSGMLID('x_ y'), 'x--y')
36 def test_SpecialCharsGetRemoved(self):
37 self.assertEquals(common.CreateValidSGMLID('x,;y'), 'xy')
40 if __name__ == '__main__':
41 unittest.main()