Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Castellum
castellum_pseudonyms
Commits
85321375
Commit
85321375
authored
Sep 30, 2020
by
Bengfort
Browse files
port tests to unittest
parent
2d776315
Changes
1
Hide whitespace changes
Inline
Side-by-side
test.py
View file @
85321375
import
py
test
import
unit
test
from
castellum_pseudonyms
import
clean
,
generate
@
pytest
.
mark
.
unittest
def
test_clean_generated
():
clean
(
generate
())
class
TestPseudonyms
(
unittest
.
TestCase
):
def
test_clean_generated
(
self
):
clean
(
generate
())
def
test_clean_invalid_checksum
(
self
):
with
self
.
assertRaises
(
ValueError
)
as
cm
:
clean
(
'foo'
)
self
.
assertNotIn
(
'invalid characters'
,
str
(
cm
.
exception
))
@
pytest
.
mark
.
unittest
def
test_clean_invalid_checksum
():
with
pytest
.
raises
(
ValueError
)
as
excinfo
:
clean
(
'foo'
)
assert
'invalid characters'
not
in
str
(
excinfo
.
value
)
def
test_clean_invalid_chars
(
self
):
with
self
.
assertRaises
(
ValueError
)
as
cm
:
clean
(
'ABC!'
)
self
.
assertIn
(
'invalid characters'
,
str
(
cm
.
exception
))
def
test_check_denormalized
(
self
):
self
.
assertEqual
(
clean
(
'vg83END03T'
),
'VG83END03T'
)
self
.
assertEqual
(
clean
(
'VG83ENDO3T'
),
'VG83END03T'
)
@
pytest
.
mark
.
unittest
def
test_clean_invalid_chars
():
with
pytest
.
raises
(
ValueError
)
as
excinfo
:
clean
(
'ABC!'
)
assert
'invalid characters'
in
str
(
excinfo
.
value
)
@
pytest
.
mark
.
unittest
def
test_check_denormalized
():
assert
clean
(
'vg83END03T'
)
==
'VG83END03T'
assert
clean
(
'VG83ENDO3T'
)
==
'VG83END03T'
if
__name__
==
'__main__'
:
unittest
.
main
()
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment