From 26dabc676ac74812f2dbcfaf0e2b7c5b21e804c9 Mon Sep 17 00:00:00 2001 From: David Luevano Alvarado Date: Tue, 14 Feb 2023 13:22:19 -0600 Subject: add simple tests and simple working solution --- tests/__init__.py | 0 tests/test_pymdvar.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 tests/__init__.py create mode 100644 tests/test_pymdvar.py (limited to 'tests') diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_pymdvar.py b/tests/test_pymdvar.py new file mode 100644 index 0000000..2e305ec --- /dev/null +++ b/tests/test_pymdvar.py @@ -0,0 +1,32 @@ +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

') +]) +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

') +]) +def test_simple_replacements(in_str, exp_str): + out_str = markdown(in_str, extensions=[VariableExtension(variables={'test':'value'})]) + assert out_str == exp_str + -- cgit v1.2.3-70-g09d2