Merge lp:~dholbach/help-app/1436316 into lp:help-app

Proposed by Daniel Holbach
Status: Merged
Approved by: Daniel Holbach
Approved revision: 134
Merged at revision: 134
Proposed branch: lp:~dholbach/help-app/1436316
Merge into: lp:help-app
Diff against target: 69 lines (+22/-8)
3 files modified
internals/tests/test_markdown.py (+10/-2)
internals/translations/build.py (+9/-3)
internals/translations/utils.py (+3/-3)
To merge this branch: bzr merge lp:~dholbach/help-app/1436316
Reviewer Review Type Date Requested Status
Nicholas Skaggs (community) Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+259007@code.launchpad.net

Commit message

Don't sys.exit() if Markdown instatiation fails, catch error in tests and elsewhere.

Description of the change

Don't sys.exit() if Markdown instatiation fails, catch error in tests and elsewhere.

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

LGTM.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'internals/tests/test_markdown.py'
2--- internals/tests/test_markdown.py 2015-03-23 15:53:43 +0000
3+++ internals/tests/test_markdown.py 2015-05-13 14:35:20 +0000
4@@ -10,14 +10,22 @@
5 TestCase.__init__(self, *args)
6
7 def test_load_extensions(self):
8- md = utils.Markdown()
9+ try:
10+ md = utils.Markdown()
11+ except ImportError:
12+ md = None
13+ self.assertIsNotNone(md)
14 for ext in MD_EXTENSIONS:
15 self.assertTrue(ext in md.md.treeprocessors or
16 ext in [q.__module__ for q
17 in md.md.registeredExtensions])
18
19 def test_convert_all_docs(self):
20- md = utils.Markdown()
21+ try:
22+ md = utils.Markdown()
23+ except ImportError:
24+ md = None
25+ self.assertIsNotNone(md)
26 docs = Documents()
27 self.assertEqual(len(docs.docs),
28 len([md.can_convert_md_file(fn) for fn
29
30=== modified file 'internals/translations/build.py'
31--- internals/translations/build.py 2015-03-31 11:38:30 +0000
32+++ internals/translations/build.py 2015-05-13 14:35:20 +0000
33@@ -233,9 +233,15 @@
34
35 class Documents(object):
36 def __init__(self):
37- md = Markdown()
38- self.docs = [fn for fn in self.find_docs()
39- if verify_file_type(fn) and md.can_convert_md_file(fn)]
40+ try:
41+ md = Markdown()
42+ except ImportError:
43+ md = None
44+ self.docs = []
45+ if md:
46+ self.docs = \
47+ [fn for fn in self.find_docs()
48+ if verify_file_type(fn) and md.can_convert_md_file(fn)]
49
50 def find_docs(self):
51 docs = []
52
53=== modified file 'internals/translations/utils.py'
54--- internals/translations/utils.py 2015-03-31 07:57:56 +0000
55+++ internals/translations/utils.py 2015-05-13 14:35:20 +0000
56@@ -69,10 +69,10 @@
57 try:
58 self.md = markdown.Markdown(extensions=MD_EXTENSIONS)
59 except ImportError:
60+ print('Could not load all markdown extensions.')
61+ raise
62+ finally:
63 os.chdir(pwd)
64- print('Could not load all markdown extensions.')
65- sys.exit(1)
66- os.chdir(pwd)
67
68 def can_convert_md_file(self, fn):
69 (ret, tmp) = tempfile.mkstemp()

Subscribers

People subscribed via source and target branches