Skip to content

Commit

Permalink
Make certain arguments non-optional and correctly run the tests. The …
Browse files Browse the repository at this point in the history
…previous code tried to discard exceptions instead of properly respectring the api contract from the tests.
  • Loading branch information
ionelmc committed Nov 5, 2015
1 parent 2a87d2b commit b424f24
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/darkslide/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ def get_js(self):
'contents': js_file_obj.read(),
}

def get_slide_vars(self, slide_src, source=None,
def get_slide_vars(self, slide_src, source,
_presenter_notes_re=re.compile(r'<h\d[^>]*>presenter notes</h\d>',
re.DOTALL | re.UNICODE | re.IGNORECASE),
_slide_title_re=re.compile(r'(<h(\d+?).*?>(.+?)</h\d>)\s?(.+)?', re.DOTALL | re.UNICODE)):
Expand Down Expand Up @@ -496,7 +496,7 @@ def parse_config(self, config_source):
config['js'] = raw_config.get('landslide', 'js').replace('\r', '').split('\n')
return config

def process_macros(self, content, source=None, context=None):
def process_macros(self, content, source, context):
""" Processed all macros.
"""
classes = []
Expand Down
12 changes: 6 additions & 6 deletions tests/test_landslide.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def test_get_toc():

def test_get_slide_vars():
g = Generator(os.path.join(DATA_DIR, 'test.md'))
svars = g.get_slide_vars("<h1>heading</h1>\n<p>foo</p>\n<p>bar</p>\n")
svars = g.get_slide_vars("<h1>heading</h1>\n<p>foo</p>\n<p>bar</p>\n", '')
assert svars['title'] == 'heading'
assert svars['level'] == 1
assert svars['header'] == '<h1>heading</h1>'
Expand Down Expand Up @@ -116,12 +116,12 @@ def test_get_template_vars():
def test_process_macros():
g = Generator(os.path.join(DATA_DIR, 'test.md'))
# Notes
r = g.process_macros('<p>foo</p>\n<p>.notes: bar</p>\n<p>baz</p>')
r = g.process_macros('<p>foo</p>\n<p>.notes: bar</p>\n<p>baz</p>', '', {})
assert r[0].find('<p class="notes">bar</p>') == 11
assert r[1] == [u'has_notes']
# FXs
content = '<p>foo</p>\n<p>.fx: blah blob</p>\n<p>baz</p>'
r = g.process_macros(content)
r = g.process_macros(content, '', {})
assert r[0] == '<p>foo</p>\n<p>baz</p>'
assert r[1][0] == 'blah'
assert r[1][1] == 'blob'
Expand All @@ -145,22 +145,22 @@ def plop(foo):
def test_presenter_notes():
g = Generator(os.path.join(DATA_DIR, 'test.md'))
svars = g.get_slide_vars("<h1>heading</h1>\n<p>foo</p>\n"
"<h1>Presenter Notes</h1>\n<p>bar</p>\n")
"<h1>Presenter Notes</h1>\n<p>bar</p>\n", '')
assert svars['presenter_notes'] == "<p>bar</p>"

# Check that presenter notes work even if the slide has no heading.
# For example, if it is only an image:

g = Generator(os.path.join(DATA_DIR, 'test.md'))
svars = g.get_slide_vars("<p>foo</p>\n"
"<h1>Presenter Notes</h1>\n<p>bar</p>\n")
"<h1>Presenter Notes</h1>\n<p>bar</p>\n", '')


def test_skip_presenter_notes():
g = Generator(os.path.join(DATA_DIR, 'test.md'),
presenter_notes=False)
svars = g.get_slide_vars("<h1>heading</h1>\n<p>foo</p>\n"
"<h1>Presenter Notes</h1>\n<p>bar</p>\n")
"<h1>Presenter Notes</h1>\n<p>bar</p>\n", '')
assert svars['presenter_notes'] == None


Expand Down

0 comments on commit b424f24

Please sign in to comment.