tools/c10e-html: run fixup conditionally
[gtk-doc.git] / tests / check.py
blob997aa6e0710d2a480ee2bc33d021f713c113d0ab
1 # -*- python -*-
3 # gtk-doc - GTK DocBook documentation generator.
4 # Copyright (C) 2017 Stefan Sauer
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 import unittest
23 from gtkdoc import check
26 class TestCheck(unittest.TestCase):
28 def test_grep_finds_token_in_one_line(self):
29 result = check.grep(r'^(foo)', ['foo'], 'foo')
30 self.assertEqual('foo', result)
32 def test_grep_does_not_find_token(self):
33 with self.assertRaises(check.FileFormatError) as ctx:
34 check.grep(r'^(foo)', ['bar'], 'foo')
35 self.assertEqual(str(ctx.exception), 'foo')
37 def test_get_variable_prefers_env(self):
38 result = check.get_variable({'foo': 'bar'}, ['foo=baz'], 'foo')
39 self.assertEqual('bar', result)
41 def test_get_variable_finds_in_file(self):
42 result = check.get_variable({}, ['foo=bar'], 'foo')
43 self.assertEqual('bar', result)
45 def test_get_variable_finds_in_file_with_whitespce(self):
46 result = check.get_variable({}, ['foo = bar'], 'foo')
47 self.assertEqual('bar', result)
49 def test_get_variable_empty_file(self):
50 with self.assertRaises(check.FileFormatError) as ctx:
51 check.get_variable({'foo': 'bar'}, [], 'foo')
52 self.assertEqual(str(ctx.exception), 'foo')
55 if __name__ == '__main__':
56 unittest.main()