import pytest from markdown import markdown from pymdvar import VariableExtension def test_empty_input(): in_str = '' out_str = markdown(in_str, extensions=[VariableExtension()]) print(in_str) print(out_str) assert in_str == out_str @pytest.mark.parametrize('in_str, exp_str', [ ('foo bar', '
foo bar
'), ('foo *test* bar', 'foo test bar
'), ('foo **test** bar', 'foo test bar
'), ('foo $test bar', 'foo $test bar
'), ('foo *${test* bar', 'foo ${test bar
'), ('foo **$test}** bar', 'foo $test} bar
'), ]) def test_non_replacements(in_str, exp_str): out_str = markdown(in_str, extensions=[VariableExtension()]) assert out_str == exp_str @pytest.mark.parametrize('in_str, exp_str', [ ('foo ${test} bar', 'foo value bar
'), ('foo *${test}* bar', 'foo value bar
'), ('foo **${test}** bar', 'foo value bar
'), ('foo [link](${test}/a.html) bar', 'foo link bar
'), ('foo ![image](${test}/a.jpg) bar', 'foo bar
'), ]) def test_simple_replacements(in_str, exp_str): out_str = markdown(in_str, extensions=[VariableExtension(variables={'test':'value'})]) assert out_str == exp_str