diff --git a/analyzer_engine/image_redactor.py b/src/analyzer_engine/image_redactor.py similarity index 100% rename from analyzer_engine/image_redactor.py rename to src/analyzer_engine/image_redactor.py diff --git a/tests/analyzer_engine/image_redactor_test.py b/tests/analyzer_engine/image_redactor_test.py index fb3e12f..9d99f87 100644 --- a/tests/analyzer_engine/image_redactor_test.py +++ b/tests/analyzer_engine/image_redactor_test.py @@ -1,22 +1,24 @@ -from unittest import TestCase - -from analyzer_engine.image_redactor import ImageRedactor +import pytest import os +import shutil +from analyzer_engine.image_redactor import ImageRedactor OUTPUT_DIR = "output" -class ImageRedactorTest(TestCase): +@pytest.fixture(scope="module") +def img_red(): + return ImageRedactor() + - def setUp(self) -> None: - self.img_red = ImageRedactor() - os.makedirs(OUTPUT_DIR, exist_ok=True) +@pytest.fixture(autouse=True, scope="module") +def setup_and_teardown(): + os.makedirs(OUTPUT_DIR, exist_ok=True) + yield + shutil.rmtree(OUTPUT_DIR) - def tearDown(self) -> None: - import shutil - shutil.rmtree(OUTPUT_DIR) - def test_detects_pii_in_image_successfully(self): - image = self.img_red.detect_pii("./data/ocr_text.png") - image.save("./output/modified.png") - self.assertTrue(os.path.isfile("./output/modified.png")) +def test_detects_pii_in_image_successfully(img_red): + image = img_red.detect_pii("./data/ocr_text.png") + image.save("./output/modified.png") + assert os.path.isfile("./output/modified.png")