| Total Complexity | 1 |
| Total Lines | 29 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | from datetime import datetime |
||
|
|
|||
| 2 | |||
| 3 | import pytest |
||
| 4 | |||
| 5 | from pocketutils.misc.magic_template import * |
||
| 6 | |||
| 7 | |||
| 8 | class TestTemplates: |
||
| 9 | def test(self): |
||
| 10 | assert MagicTemplate.from_text("abc ${{x}}").add("x", 1).parse() == "abc 1" |
||
| 11 | assert ( |
||
| 12 | MagicTemplate.from_text("abc ${{minor}} ${{major}} ${{patch}}") |
||
| 13 | .add_version("1.3.9") |
||
| 14 | .parse() |
||
| 15 | == "abc 3 1 9" |
||
| 16 | ) |
||
| 17 | at = datetime(2001, 2, 2) |
||
| 18 | assert ( |
||
| 19 | MagicTemplate.from_text("abc ${{datetuple}}").add_datetime(at).parse() |
||
| 20 | == "abc (2001, 2, 2)" |
||
| 21 | ) |
||
| 22 | assert ( |
||
| 23 | MagicTemplate.from_text("abc ${{datetuple}}").add_datetime().parse().startswith("abc") |
||
| 24 | ) |
||
| 25 | |||
| 26 | |||
| 27 | if __name__ == "__main__": |
||
| 28 | pytest.main() |
||
| 29 |