[gtk-doc] check: simplify custom exception
- From: Stefan Sauer <stefkost src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk-doc] check: simplify custom exception
- Date: Mon, 17 Apr 2017 17:50:27 +0000 (UTC)
commit a44ecff27385f1d0b072ec7e09bbaf70bda8e4c0
Author: Stefan Sauer <ensonic users sf net>
Date: Mon Apr 17 19:45:33 2017 +0200
check: simplify custom exception
gtkdoc/check.py | 8 +++-----
tests/gtkdoc-check.py | 6 ++++--
2 files changed, 7 insertions(+), 7 deletions(-)
---
diff --git a/gtkdoc/check.py b/gtkdoc/check.py
index a4e93d8..de5eafd 100755
--- a/gtkdoc/check.py
+++ b/gtkdoc/check.py
@@ -34,9 +34,7 @@ from glob import glob
class FileFormatError(Exception):
-
- def __init__(self, detail):
- self.detail = detail
+ pass
def grep(regexp, lines, what):
@@ -93,7 +91,7 @@ def run_tests(workdir, doc_module, doc_main_file):
incomplete = int(grep(r'^(\d+)\s+symbols?\s+incomplete\.\s*$',
statusfile, 'number of incomplete symbols'))
except FileFormatError as e:
- print('Cannot find %s in %s' % (e.detail, statusfilename))
+ print('Cannot find %s in %s' % (str(e), statusfilename))
return checks # consider all failed
total = undocumented + incomplete
@@ -143,7 +141,7 @@ def run(options=None):
doc_module = get_variable(os.environ, makefile, 'DOC_MODULE')
doc_main_file = get_variable(os.environ, makefile, 'DOC_MAIN_SGML_FILE')
except FileFormatError as e:
- print('Cannot find %s in %s' % (e.detail, makefilename))
+ print('Cannot find %s in %s' % (str(e), makefilename))
return 1
doc_main_file = doc_main_file.replace('$(DOC_MODULE)', doc_module)
diff --git a/tests/gtkdoc-check.py b/tests/gtkdoc-check.py
index 6cab062..b8e2b6d 100755
--- a/tests/gtkdoc-check.py
+++ b/tests/gtkdoc-check.py
@@ -4,7 +4,9 @@ import unittest
from gtkdoc import check
+
class TestCheck(unittest.TestCase):
+
def test_grep_finds_token_in_one_line(self):
result = check.grep(r'^(foo)', ['foo'], 'foo')
self.assertEqual('foo', result)
@@ -12,10 +14,10 @@ class TestCheck(unittest.TestCase):
def test_grep_does_not_find_token(self):
with self.assertRaises(check.FileFormatError) as ctx:
check.grep(r'^(foo)', ['bar'], 'foo')
- self.assertEqual(ctx.exception.detail, 'foo')
+ self.assertEqual(str(ctx.exception), 'foo')
def test_get_variable_prefers_env(self):
- result = check.get_variable({'foo':'bar'}, ['foo=baz'], 'foo')
+ result = check.get_variable({'foo': 'bar'}, ['foo=baz'], 'foo')
self.assertEqual('bar', result)
def test_get_variable_finds_in_file(self):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]