Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
diceware-debian
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
drebs
diceware-debian
Commits
6ff26c93
Commit
6ff26c93
authored
9 years ago
by
ulif
Browse files
Options
Downloads
Patches
Plain Diff
Add tests for options.
parent
a7d79d26
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_diceware.py
+19
-0
19 additions, 0 deletions
tests/test_diceware.py
with
19 additions
and
0 deletions
tests/test_diceware.py
+
19
−
0
View file @
6ff26c93
...
...
@@ -7,6 +7,7 @@ from io import StringIO
from
diceware
import
(
WORDLISTS_DIR
,
SPECIAL_CHARS
,
insert_special_char
,
get_passphrase
,
handle_options
,
main
,
__version__
,
print_version
,
get_random_sources
,
get_wordlist_names
)
...
...
@@ -145,6 +146,7 @@ class TestDicewareModule(object):
assert
options
.
version
is
False
assert
options
.
delimiter
==
""
assert
options
.
randomsource
==
"
system
"
assert
options
.
wordlist
==
"
en_8k
"
def
test_handle_options_infile
(
self
,
tmpdir
):
# we can give an infile
...
...
@@ -186,6 +188,23 @@ class TestDicewareModule(object):
assert
out
==
''
assert
"
invalid choice
"
in
err
def
test_handle_options_wordlist
(
self
,
capsys
):
# we can pick a wordlist
wordlist_names
=
get_wordlist_names
()
for
name
in
wordlist_names
:
options
=
handle_options
([
'
-w
'
,
name
])
assert
options
.
wordlist
==
name
options
=
handle_options
([
'
--wordlist
'
,
name
])
assert
options
.
wordlist
==
name
def
test_handle_options_wordlist_rejects_invalid
(
self
,
capsys
):
# we can choose only existing wordlists
with
pytest
.
raises
(
SystemExit
):
handle_options
([
'
-w
'
,
'
not-a-valid-wordlist-name
'
])
out
,
err
=
capsys
.
readouterr
()
assert
out
==
''
assert
"
invalid choice
"
in
err
def
test_main
(
self
,
capsys
):
# we can get a passphrase
main
([])
# call with default options in place
...
...
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