Skip to content
Snippets Groups Projects
Commit 28c0d3c7 authored by Yoann Schneider's avatar Yoann Schneider :tennis:
Browse files

Merge branch 'test-remove-pytest-lazy-fixture' into 'main'

Remove `pytest-lazy-fixture`

Closes #258

See merge request !352
parents 88024ccd 751b076c
No related branches found
No related tags found
1 merge request!352Remove `pytest-lazy-fixture`
...@@ -28,80 +28,53 @@ def full_statistics(): ...@@ -28,80 +28,53 @@ def full_statistics():
return MdUtils(file_name="").read_md_file(str(FIXTURES / "analyze" / "stats")) return MdUtils(file_name="").read_md_file(str(FIXTURES / "analyze" / "stats"))
@pytest.mark.parametrize( def test_display_image_statistics(image_statistics, tmp_path):
"im_paths, expected_summary",
(
(
[
"tests/data/training/training_dataset/images/0a34e13a-4ab0-4a91-8d7c-b1d8fee32628.png",
"tests/data/training/training_dataset/images/0a70e14f-feda-4607-989c-36cf581ddff5.png",
"tests/data/training/training_dataset/images/0a576062-303c-4893-a729-c09c92865d31.png",
"tests/data/training/training_dataset/images/0b2457c8-81f1-4600-84d9-f8bf2822a991.png",
"tests/data/training/training_dataset/images/fb3edb59-3678-49f8-8e16-8e32e3b0f051.png",
"tests/data/training/training_dataset/images/fe498de2-ece4-4fbe-8b53-edfce1b820f0.png",
],
pytest.lazy_fixture("image_statistics"),
),
),
)
def test_display_image_statistics(im_paths, expected_summary, tmp_path):
stats = Statistics(filename=tmp_path) stats = Statistics(filename=tmp_path)
stats.create_image_statistics(images=im_paths) stats.create_image_statistics(
assert stats.document.get_md_text() == expected_summary images=[
"tests/data/training/training_dataset/images/0a34e13a-4ab0-4a91-8d7c-b1d8fee32628.png",
"tests/data/training/training_dataset/images/0a70e14f-feda-4607-989c-36cf581ddff5.png",
@pytest.mark.parametrize( "tests/data/training/training_dataset/images/0a576062-303c-4893-a729-c09c92865d31.png",
"texts, expected_summary", "tests/data/training/training_dataset/images/0b2457c8-81f1-4600-84d9-f8bf2822a991.png",
( "tests/data/training/training_dataset/images/fb3edb59-3678-49f8-8e16-8e32e3b0f051.png",
( "tests/data/training/training_dataset/images/fe498de2-ece4-4fbe-8b53-edfce1b820f0.png",
[ ]
"Teklia’s expertise is to develop document analysis\nand processing solutions using, among other things,\nOCR technology.", )
"Our software combines image analysis, printed and\nhandwritten text recognition, text segmentation with\na document classification and indexation system.", assert stats.document.get_md_text() == image_statistics
"Our objective is to deliver to our clients an automated\ndocument processing tool easy-to-use and adapted\nto their needs.",
"With the same state of mind, we developed additional solutions to\nenhance both security and business-process.",
], def test_display_label_statistics(labels_statistics, tmp_path):
pytest.lazy_fixture("labels_statistics"),
),
),
)
def test_display_label_statistics(texts, expected_summary, tmp_path):
filename = tmp_path / "labels.md" filename = tmp_path / "labels.md"
stats = Statistics(filename=str(filename)) stats = Statistics(filename=str(filename))
stats.create_label_statistics(labels=texts) stats.create_label_statistics(
assert stats.document.get_md_text() == expected_summary labels=[
"Teklia’s expertise is to develop document analysis\nand processing solutions using, among other things,\nOCR technology.",
"Our software combines image analysis, printed and\nhandwritten text recognition, text segmentation with\na document classification and indexation system.",
@pytest.mark.parametrize( "Our objective is to deliver to our clients an automated\ndocument processing tool easy-to-use and adapted\nto their needs.",
"texts, expected_summary", "With the same state of mind, we developed additional solutions to\nenhance both security and business-process.",
( ]
( )
[ assert stats.document.get_md_text() == labels_statistics
"ⓈDayon ⒻFernand Ⓐ6\nⓈDayen ⒻMaurice Ⓐ2\nⓈTottelier ⒻJean Baptiste Ⓐ59",
"ⓈPeryro ⒻEtienne Ⓐ33\nⓈJeannot ⒻCaroline Ⓐ24\nⓈMouline ⒻPierre Ⓐ32",
], def test_display_ner_statistics(ner_statistics, tmp_path):
pytest.lazy_fixture("ner_statistics"),
),
),
)
def test_display_ner_statistics(texts, expected_summary, tmp_path):
tokens = read_yaml(FIXTURES / "training" / "training_dataset" / "tokens.yaml") tokens = read_yaml(FIXTURES / "training" / "training_dataset" / "tokens.yaml")
stats = Statistics(filename=tmp_path) stats = Statistics(filename=tmp_path)
stats.create_ner_statistics(labels=texts, ner_tokens=tokens) stats.create_ner_statistics(
assert stats.document.get_md_text() == expected_summary labels=[
"ⓈDayon ⒻFernand Ⓐ6\nⓈDayen ⒻMaurice Ⓐ2\nⓈTottelier ⒻJean Baptiste Ⓐ59",
"ⓈPeryro ⒻEtienne Ⓐ33\nⓈJeannot ⒻCaroline Ⓐ24\nⓈMouline ⒻPierre Ⓐ32",
@pytest.mark.parametrize( ],
"labels, tokens, expected_summary", ner_tokens=tokens,
( )
( assert stats.document.get_md_text() == ner_statistics
FIXTURES / "training" / "training_dataset" / "labels.json",
FIXTURES / "training" / "training_dataset" / "tokens.yaml",
pytest.lazy_fixture("full_statistics"), def test_run(full_statistics, tmp_path):
),
),
)
def test_run(labels, tokens, expected_summary, tmp_path):
output_file = tmp_path / "stats.md" output_file = tmp_path / "stats.md"
stats = Statistics(filename=str(output_file)) stats = Statistics(filename=str(output_file))
stats.run(labels=read_json(labels), tokens=read_yaml(tokens)) stats.run(
assert output_file.read_text() == expected_summary labels=read_json(FIXTURES / "training" / "training_dataset" / "labels.json"),
tokens=read_yaml(FIXTURES / "training" / "training_dataset" / "tokens.yaml"),
)
assert output_file.read_text() == full_statistics
...@@ -8,9 +8,7 @@ description = run the tests with pytest ...@@ -8,9 +8,7 @@ description = run the tests with pytest
package = wheel package = wheel
wheel_build_env = .pkg wheel_build_env = .pkg
deps = deps =
# TODO: Remove this once https://gitlab.teklia.com/atr/dan/-/issues/258 is done pytest>=6
pytest<8,>=6
pytest-lazy-fixture
pytest-responses pytest-responses
-rrequirements.txt -rrequirements.txt
commands = commands =
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment