Skip to content
Permalink
Browse files

Adjust tests for data always existing

Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Dec 23, 2015
1 parent 79ab0a1 commit beb6b8704e5de53b99ea37b9b6e336157005315c
Showing with 8 additions and 8 deletions.
  1. +8 −8 tests/test_shortcodes.py
@@ -8,13 +8,13 @@
from nikola import shortcodes
from .base import FakeSite

def noargs(site, data=':'):
def noargs(site, data=''):
return "noargs {0} success!".format(data)

def arg(*args, **kwargs):
# don’t clutter the kwargs dict
_ = kwargs.pop('site')
data = kwargs.pop('data', None)
data = kwargs.pop('data')
return "arg {0}/{1}/{2}".format(args, sorted(kwargs.items()), data)


@@ -26,18 +26,18 @@ def fakesite():
return s

def test_noargs(fakesite):
assert shortcodes.apply_shortcodes('test({{% noargs %}})', fakesite.shortcode_registry) == 'test(noargs : success!)'
assert shortcodes.apply_shortcodes('test({{% noargs %}})', fakesite.shortcode_registry) == 'test(noargs success!)'
assert shortcodes.apply_shortcodes('test({{% noargs %}}\\hello world/{{% /noargs %}})', fakesite.shortcode_registry) == 'test(noargs \\hello world/ success!)'

def test_arg_pos(fakesite):
assert shortcodes.apply_shortcodes('test({{% arg 1 %}})', fakesite.shortcode_registry) == "test(arg ('1',)/[]/None)"
assert shortcodes.apply_shortcodes('test({{% arg 1 2aa %}})', fakesite.shortcode_registry) == "test(arg ('1', '2aa')/[]/None)"
assert shortcodes.apply_shortcodes('test({{% arg 1 %}})', fakesite.shortcode_registry) == "test(arg ('1',)/[]/)"
assert shortcodes.apply_shortcodes('test({{% arg 1 2aa %}})', fakesite.shortcode_registry) == "test(arg ('1', '2aa')/[]/)"
# TODO: currently unsupported!
# assert shortcodes.apply_shortcodes('test({{% arg "hello world" %}})', fakesite.shortcode_registry) == "test(arg ('hello world',)/[]/None)"
# assert shortcodes.apply_shortcodes('test({{% arg "hello world" %}})', fakesite.shortcode_registry) == "test(arg ('hello world',)/[]/)"

def test_arg_keyword(fakesite):
assert shortcodes.apply_shortcodes('test({{% arg 1a=2b %}})', fakesite.shortcode_registry) == "test(arg ()/[('1a', '2b')]/None)"
assert shortcodes.apply_shortcodes('test({{% arg 1a="2b 3c" 4d=5f %}})', fakesite.shortcode_registry) == "test(arg ()/[('1a', '2b 3c'), ('4d', '5f')]/None)"
assert shortcodes.apply_shortcodes('test({{% arg 1a=2b %}})', fakesite.shortcode_registry) == "test(arg ()/[('1a', '2b')]/)"
assert shortcodes.apply_shortcodes('test({{% arg 1a="2b 3c" 4d=5f %}})', fakesite.shortcode_registry) == "test(arg ()/[('1a', '2b 3c'), ('4d', '5f')]/)"

def test_data(fakesite):
assert shortcodes.apply_shortcodes('test({{% arg 123 %}}Hello!{{% /arg %}})', fakesite.shortcode_registry) == "test(arg ('123',)/[]/Hello!)"

0 comments on commit beb6b87

Please sign in to comment.
You can’t perform that action at this time.