chore: pytest: Add pytest and enclose the tests in a new class TestUtils

This commit is contained in:
Dennis Priskorn 2024-08-28 11:54:05 +02:00
parent 171d13f9ca
commit 8990daec21
2 changed files with 21 additions and 21 deletions

View file

@ -11,3 +11,4 @@ simplejson
user_agents user_agents
num2words num2words
psycopg2 psycopg2
pytest===8.3.2

View file

@ -1,15 +1,16 @@
"""Test matcher utils.""" """Test matcher utils."""
from unittest import TestCase
from matcher import utils from matcher import utils
def test_format_wikibase_time_year() -> None: class TestUtils(TestCase):
def test_format_wikibase_time_year(self) -> None:
"""Test passing a year to format_wikibase_time.""" """Test passing a year to format_wikibase_time."""
v = {"time": "+1950-00-00T00:00:00Z", "precision": 9} v = {"time": "+1950-00-00T00:00:00Z", "precision": 9}
assert utils.format_wikibase_time(v) == "1950" assert utils.format_wikibase_time(v) == "1950"
def test_format_wikibase_time_century(self) -> None:
def test_format_wikibase_time_century() -> None:
"""Test passing centuries to format_wikibase_time.""" """Test passing centuries to format_wikibase_time."""
v = {"time": "+0800-00-00T00:00:00Z", "precision": 7} v = {"time": "+0800-00-00T00:00:00Z", "precision": 7}
assert utils.format_wikibase_time(v) == "8th century" assert utils.format_wikibase_time(v) == "8th century"
@ -17,14 +18,12 @@ def test_format_wikibase_time_century() -> None:
v = {"time": "+1950-00-00T00:00:00Z", "precision": 7} v = {"time": "+1950-00-00T00:00:00Z", "precision": 7}
assert utils.format_wikibase_time(v) == "20th century" assert utils.format_wikibase_time(v) == "20th century"
def test_format_wikibase_time_decade(self) -> None:
def test_format_wikibase_time_decade() -> None:
"""Test passing a full date to format_wikibase_time.""" """Test passing a full date to format_wikibase_time."""
v = {"time": "+1910-00-00T00:00:00Z", "precision": 8} v = {"time": "+1910-00-00T00:00:00Z", "precision": 8}
assert utils.format_wikibase_time(v) == "1910s" assert utils.format_wikibase_time(v) == "1910s"
def test_format_wikibase_time_day(self) -> None:
def test_format_wikibase_time_day() -> None:
"""Test passing a full date to format_wikibase_time.""" """Test passing a full date to format_wikibase_time."""
v = {"time": "+1868-01-09T00:00:00Z", "precision": 11} v = {"time": "+1868-01-09T00:00:00Z", "precision": 11}
assert utils.format_wikibase_time(v) == "9 January 1868" assert utils.format_wikibase_time(v) == "9 January 1868"