diff options
author | rsiddharth <rsd@gnu.org> | 2019-07-13 18:47:08 -0400 |
---|---|---|
committer | rsiddharth <rsd@gnu.org> | 2019-07-13 18:47:08 -0400 |
commit | df19a818d8e7091d1d3a2b8d9c31954a50665a23 (patch) | |
tree | d0e935a07bd1101ba017ceebd619d718dd3e77dd | |
parent | 8ca7c73df5994a30f3b1070f8c000beef454849e (diff) |
lps_gen.py: Update template_read.
* lps_gen.py (template_read): Add exception handling for non-existent
templates.
* tests/test_lps_gen.py (TestTemplates.test_read): Add non-existent
template test.
-rw-r--r-- | lps_gen.py | 8 | ||||
-rw-r--r-- | tests/test_lps_gen.py | 3 |
2 files changed, 10 insertions, 1 deletions
@@ -99,7 +99,13 @@ def template_read(name): p = 'lpschedule_generator' r = 'data/{}'.format(name) - return pkgr.resource_string(p, r).decode('utf-8') + t = None + try: + t = pkgr.resource_string(p, r).decode('utf-8') + except Exception as e: + print(e, file=sys.stderr) + + return t class LPiCal(object): diff --git a/tests/test_lps_gen.py b/tests/test_lps_gen.py index 26c6132..c4ff1dd 100644 --- a/tests/test_lps_gen.py +++ b/tests/test_lps_gen.py @@ -113,6 +113,9 @@ class TestTemplates(object): assert type(t) is str assert len(t) > 0 + t = template_read('nonexistent.jinja2') + assert t is None + class TestLPiCal(object): """ |