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
6fe18e9b
Commit
6fe18e9b
authored
10 years ago
by
ulif
Browse files
Options
Downloads
Patches
Plain Diff
Use opts in main().
parent
e20181f0
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
diceware/diceware.py
+5
-2
5 additions, 2 deletions
diceware/diceware.py
tests/test_diceware.py
+8
-1
8 additions, 1 deletion
tests/test_diceware.py
with
13 additions
and
3 deletions
diceware/diceware.py
+
5
−
2
View file @
6fe18e9b
import
argparse
import
os
import
re
import
sys
from
random
import
SystemRandom
...
...
@@ -69,5 +70,7 @@ def get_passphrase(wordnum=6, specials=True, separator='', lang='en',
return
result
def
main
():
pass
def
main
(
args
=
1
):
if
args
is
1
:
args
=
sys
.
argv
[
1
:]
options
=
handle_options
(
args
)
This diff is collapsed.
Click to expand it.
tests/test_diceware.py
+
8
−
1
View file @
6fe18e9b
...
...
@@ -3,6 +3,7 @@ import pytest
import
sys
from
diceware.diceware
import
(
SRC_DIR
,
get_wordlist
,
get_wordlist_path
,
get_passphrase
,
handle_options
,
main
,
)
...
...
@@ -55,11 +56,17 @@ class TestDicewareModule(object):
r2
=
get_passphrase
()
assert
r1
!=
r2
def
test_handle_options
(
self
,
capsys
):
def
test_handle_options
(
self
):
# we can get help
with
pytest
.
raises
(
SystemExit
)
as
exc_info
:
handle_options
([
'
--help
'
])
assert
exc_info
.
value
.
code
==
0
def
test_main
(
self
,
capsys
):
# we can get help
with
pytest
.
raises
(
SystemExit
)
as
exc_info
:
main
([
'
diceware
'
,
'
--help
'
])
assert
exc_info
.
value
.
code
==
0
out
,
err
=
capsys
.
readouterr
()
out
=
out
.
replace
(
os
.
path
.
basename
(
sys
.
argv
[
0
]),
'
diceware
'
)
...
...
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