Skip to content

Commit

Permalink
Add initial StataTranslator tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hugetim authored Oct 17, 2024
1 parent 5384731 commit cee35c5
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions papermill/tests/test_translators.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,3 +628,41 @@ def test_translate_comment_sh(test_input, expected):
)
def test_translate_codify_sh(parameters, expected):
assert translators.BashTranslator.codify(parameters) == expected


# Stata section
@pytest.mark.parametrize(
"test_input,expected",
[
("foo", """`"foo"'"""),
("foo bar", """`"foo bar"'"""),
('foo"bar', """`"foo"bar"'"""),
(12345, '12345'),
(-54321, '-54321'),
(1.2345, '1.2345'),
(-5432.1, '-5432.1'),
(True, '1'),
(False, '0'),
(None, '""'),
],
)
def test_translate_type_r(test_input, expected):
assert translators.StataTranslator.translate(test_input) == expected


@pytest.mark.parametrize("test_input,expected", [("", '*'), ("foo", '* foo'), ("['best effort']", "* ['best effort']")])
def test_translate_comment_r(test_input, expected):
assert translators.StataTranslator.comment(test_input) == expected


@pytest.mark.parametrize(
"parameters,expected",
[
({"foo": "bar"}, '* Parameters\nglobal foo = "bar"\n'),
({"foo": True}, '* Parameters\nglobal foo = 1\n'),
({"foo": 5}, '* Parameters\nglobal foo = 5\n'),
({"foo": 1.1}, '* Parameters\nglobal foo = 1.1\n'),
],
)
def test_translate_codify_r(parameters, expected):
assert translators.StataTranslator.codify(parameters) == expected

0 comments on commit cee35c5

Please sign in to comment.