Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
DAN
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Container Registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Automatic Text Recognition
DAN
Commits
751b076c
Commit
751b076c
authored
1 year ago
by
Manon Blanco
Committed by
Yoann Schneider
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Remove `pytest-lazy-fixture`
parent
88024ccd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!352
Remove `pytest-lazy-fixture`
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/test_analyze.py
+43
-70
43 additions, 70 deletions
tests/test_analyze.py
tox.ini
+1
-3
1 addition, 3 deletions
tox.ini
with
44 additions
and
73 deletions
tests/test_analyze.py
+
43
−
70
View file @
751b076c
...
...
@@ -28,80 +28,53 @@ def full_statistics():
return
MdUtils
(
file_name
=
""
).
read_md_file
(
str
(
FIXTURES
/
"
analyze
"
/
"
stats
"
))
@pytest.mark.parametrize
(
"
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
):
def
test_display_image_statistics
(
image_statistics
,
tmp_path
):
stats
=
Statistics
(
filename
=
tmp_path
)
stats
.
create_image_statistics
(
images
=
im_paths
)
assert
stats
.
document
.
get_md_text
()
==
expected_summary
@pytest.mark.parametrize
(
"
texts, expected_summary
"
,
(
(
[
"
Teklia’s expertise is to develop document analysis
\n
and processing solutions using, among other things,
\n
OCR technology.
"
,
"
Our software combines image analysis, printed and
\n
handwritten text recognition, text segmentation with
\n
a document classification and indexation system.
"
,
"
Our objective is to deliver to our clients an automated
\n
document processing tool easy-to-use and adapted
\n
to their needs.
"
,
"
With the same state of mind, we developed additional solutions to
\n
enhance both security and business-process.
"
,
],
pytest
.
lazy_fixture
(
"
labels_statistics
"
),
),
),
)
def
test_display_label_statistics
(
texts
,
expected_summary
,
tmp_path
):
stats
.
create_image_statistics
(
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
"
,
"
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
"
,
]
)
assert
stats
.
document
.
get_md_text
()
==
image_statistics
def
test_display_label_statistics
(
labels_statistics
,
tmp_path
):
filename
=
tmp_path
/
"
labels.md
"
stats
=
Statistics
(
filename
=
str
(
filename
))
stats
.
create_label_statistics
(
labels
=
texts
)
assert
stats
.
document
.
get_md_text
()
==
expected_summary
@pytest.mark.parametrize
(
"
texts, expected_summary
"
,
(
(
[
"
ⓈDayon ⒻFernand Ⓐ6
\n
ⓈDayen ⒻMaurice Ⓐ2
\n
ⓈTottelier ⒻJean Baptiste Ⓐ59
"
,
"
ⓈPeryro ⒻEtienne Ⓐ33
\n
ⓈJeannot ⒻCaroline Ⓐ24
\n
ⓈMouline ⒻPierre Ⓐ32
"
,
],
pytest
.
lazy_fixture
(
"
ner_statistics
"
),
),
),
)
def
test_display_ner_statistics
(
texts
,
expected_summary
,
tmp_path
):
stats
.
create_label_statistics
(
labels
=
[
"
Teklia’s expertise is to develop document analysis
\n
and processing solutions using, among other things,
\n
OCR technology.
"
,
"
Our software combines image analysis, printed and
\n
handwritten text recognition, text segmentation with
\n
a document classification and indexation system.
"
,
"
Our objective is to deliver to our clients an automated
\n
document processing tool easy-to-use and adapted
\n
to their needs.
"
,
"
With the same state of mind, we developed additional solutions to
\n
enhance both security and business-process.
"
,
]
)
assert
stats
.
document
.
get_md_text
()
==
labels_statistics
def
test_display_ner_statistics
(
ner_statistics
,
tmp_path
):
tokens
=
read_yaml
(
FIXTURES
/
"
training
"
/
"
training_dataset
"
/
"
tokens.yaml
"
)
stats
=
Statistics
(
filename
=
tmp_path
)
stats
.
create_ner_statistics
(
labels
=
texts
,
ner_tokens
=
tokens
)
assert
stats
.
document
.
get_md_text
()
==
expected_summary
@pytest.mark.parametrize
(
"
labels, tokens, expected_summary
"
,
(
(
FIXTURES
/
"
training
"
/
"
training_dataset
"
/
"
labels.json
"
,
FIXTURES
/
"
training
"
/
"
training_dataset
"
/
"
tokens.yaml
"
,
pytest
.
lazy_fixture
(
"
full_statistics
"
),
),
),
)
def
test_run
(
labels
,
tokens
,
expected_summary
,
tmp_path
):
stats
.
create_ner_statistics
(
labels
=
[
"
ⓈDayon ⒻFernand Ⓐ6
\n
ⓈDayen ⒻMaurice Ⓐ2
\n
ⓈTottelier ⒻJean Baptiste Ⓐ59
"
,
"
ⓈPeryro ⒻEtienne Ⓐ33
\n
ⓈJeannot ⒻCaroline Ⓐ24
\n
ⓈMouline ⒻPierre Ⓐ32
"
,
],
ner_tokens
=
tokens
,
)
assert
stats
.
document
.
get_md_text
()
==
ner_statistics
def
test_run
(
full_statistics
,
tmp_path
):
output_file
=
tmp_path
/
"
stats.md
"
stats
=
Statistics
(
filename
=
str
(
output_file
))
stats
.
run
(
labels
=
read_json
(
labels
),
tokens
=
read_yaml
(
tokens
))
assert
output_file
.
read_text
()
==
expected_summary
stats
.
run
(
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
This diff is collapsed.
Click to expand it.
tox.ini
+
1
−
3
View file @
751b076c
...
...
@@ -8,9 +8,7 @@ description = run the tests with pytest
package
=
wheel
wheel_build_env
=
.pkg
deps
=
# TODO: Remove this once https://gitlab.teklia.com/atr/dan/-/issues/258 is done
pytest<8,>=6
pytest-lazy-fixture
pytest>=6
pytest-responses
-rrequirements.txt
commands
=
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment