From 8990daec21897dcb5e66f95ea07044e86a426308 Mon Sep 17 00:00:00 2001 From: Dennis Priskorn Date: Wed, 28 Aug 2024 11:54:05 +0200 Subject: [PATCH] chore: pytest: Add pytest and enclose the tests in a new class TestUtils --- requirements.txt | 1 + tests/test_utils.py | 41 ++++++++++++++++++++--------------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/requirements.txt b/requirements.txt index 1a601c3..5e48821 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,3 +11,4 @@ simplejson user_agents num2words psycopg2 +pytest===8.3.2 \ No newline at end of file diff --git a/tests/test_utils.py b/tests/test_utils.py index c9f6c7f..823678e 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -1,30 +1,29 @@ """Test matcher utils.""" +from unittest import TestCase from matcher import utils -def test_format_wikibase_time_year() -> None: - """Test passing a year to format_wikibase_time.""" - v = {"time": "+1950-00-00T00:00:00Z", "precision": 9} - assert utils.format_wikibase_time(v) == "1950" +class TestUtils(TestCase): + def test_format_wikibase_time_year(self) -> None: + """Test passing a year to format_wikibase_time.""" + v = {"time": "+1950-00-00T00:00:00Z", "precision": 9} + assert utils.format_wikibase_time(v) == "1950" + def test_format_wikibase_time_century(self) -> None: + """Test passing centuries to format_wikibase_time.""" + v = {"time": "+0800-00-00T00:00:00Z", "precision": 7} + assert utils.format_wikibase_time(v) == "8th century" -def test_format_wikibase_time_century() -> None: - """Test passing centuries to format_wikibase_time.""" - v = {"time": "+0800-00-00T00:00:00Z", "precision": 7} - assert utils.format_wikibase_time(v) == "8th century" + v = {"time": "+1950-00-00T00:00:00Z", "precision": 7} + assert utils.format_wikibase_time(v) == "20th century" - v = {"time": "+1950-00-00T00:00:00Z", "precision": 7} - assert utils.format_wikibase_time(v) == "20th century" + def test_format_wikibase_time_decade(self) -> None: + """Test passing a full date to format_wikibase_time.""" + v = {"time": "+1910-00-00T00:00:00Z", "precision": 8} + assert utils.format_wikibase_time(v) == "1910s" - -def test_format_wikibase_time_decade() -> None: - """Test passing a full date to format_wikibase_time.""" - v = {"time": "+1910-00-00T00:00:00Z", "precision": 8} - assert utils.format_wikibase_time(v) == "1910s" - - -def test_format_wikibase_time_day() -> None: - """Test passing a full date to format_wikibase_time.""" - v = {"time": "+1868-01-09T00:00:00Z", "precision": 11} - assert utils.format_wikibase_time(v) == "9 January 1868" + def test_format_wikibase_time_day(self) -> None: + """Test passing a full date to format_wikibase_time.""" + v = {"time": "+1868-01-09T00:00:00Z", "precision": 11} + assert utils.format_wikibase_time(v) == "9 January 1868"