Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
plotID_python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
plotID
plotID_python
Commits
1cafa1cf
Commit
1cafa1cf
authored
2 years ago
by
Mayr, Hannes
Browse files
Options
Downloads
Patches
Plain Diff
Add unittest for wrong font file.
parent
128c3ec2
Branches
Issue/2221-projectDateCreated
No related tags found
1 merge request
!60
Enable customization of plotted IDs
Pipeline
#888184
passed
2 years ago
Stage: linting
Stage: testing
Stage: security
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
plotid/tagplot_image.py
+1
-1
1 addition, 1 deletion
plotid/tagplot_image.py
tests/test_tagplot_image.py
+7
-0
7 additions, 0 deletions
tests/test_tagplot_image.py
with
8 additions
and
1 deletion
plotid/tagplot_image.py
+
1
−
1
View file @
1cafa1cf
...
@@ -39,7 +39,7 @@ def tagplot_image(plotid_object: PlotOptions) -> PlotIDTransfer:
...
@@ -39,7 +39,7 @@ def tagplot_image(plotid_object: PlotOptions) -> PlotIDTransfer:
if
not
isinstance
(
img
,
str
):
if
not
isinstance
(
img
,
str
):
raise
TypeError
(
"
Name of the image is not a string.
"
)
raise
TypeError
(
"
Name of the image is not a string.
"
)
if
not
os
.
path
.
isfile
(
img
):
if
not
os
.
path
.
isfile
(
img
):
raise
TypeError
(
"
File
does not exist.
"
)
raise
TypeError
(
f
"
Image
'
{
img
}
'
does not exist.
"
)
# Check if figs is a valid file is done by pillow internally
# Check if figs is a valid file is done by pillow internally
color
=
tuple
(
rgb_value
*
255
for
rgb_value
in
plotid_object
.
fontcolor
)
color
=
tuple
(
rgb_value
*
255
for
rgb_value
in
plotid_object
.
fontcolor
)
...
...
This diff is collapsed.
Click to expand it.
tests/test_tagplot_image.py
+
7
−
0
View file @
1cafa1cf
...
@@ -88,6 +88,13 @@ class TestTagplotImage(unittest.TestCase):
...
@@ -88,6 +88,13 @@ class TestTagplotImage(unittest.TestCase):
with
self
.
assertRaises
(
TypeError
):
with
self
.
assertRaises
(
TypeError
):
tagplot_image
(
"
wrong_object
"
)
tagplot_image
(
"
wrong_object
"
)
def
test_font_file_not_defined
(
self
)
->
None
:
"""
Test if a Warning is raised if an invalid font file was specified.
"""
options
=
PlotOptions
(
IMG1
,
ROTATION
,
POSITION
,
font
=
"
font
"
)
options
.
validate_input
()
with
self
.
assertWarns
(
Warning
):
tagplot_image
(
options
)
def
tearDown
(
self
)
->
None
:
def
tearDown
(
self
)
->
None
:
os
.
remove
(
IMG1
)
os
.
remove
(
IMG1
)
os
.
remove
(
IMG2
)
os
.
remove
(
IMG2
)
...
...
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