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
e6e0519d
Commit
e6e0519d
authored
7 years ago
by
ulif
Browse files
Options
Downloads
Patches
Plain Diff
Add test for wordlist on stdin.
parent
58062938
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_wordlist.py
+12
-0
12 additions, 0 deletions
tests/test_wordlist.py
with
12 additions
and
0 deletions
tests/test_wordlist.py
+
12
−
0
View file @
e6e0519d
import
os
import
os
import
pytest
import
pytest
import
sys
from
io
import
StringIO
from
diceware.wordlist
import
(
from
diceware.wordlist
import
(
WORDLISTS_DIR
,
RE_WORDLIST_NAME
,
RE_NUMBERED_WORDLIST_ENTRY
,
WORDLISTS_DIR
,
RE_WORDLIST_NAME
,
RE_NUMBERED_WORDLIST_ENTRY
,
RE_VALID_WORDLIST_FILENAME
,
get_wordlist_path
,
get_wordlist_names
,
RE_VALID_WORDLIST_FILENAME
,
get_wordlist_path
,
get_wordlist_names
,
...
@@ -244,6 +246,16 @@ class TestWordList(object):
...
@@ -244,6 +246,16 @@ class TestWordList(object):
result
=
list
(
WordList
(
str
(
in_file
)))
result
=
list
(
WordList
(
str
(
in_file
)))
assert
[
'
a
'
,
'
b
'
]
==
result
assert
[
'
a
'
,
'
b
'
]
==
result
def
test_get_wordlist_stdin
(
self
,
argv_handler
):
# we can get a wordlist from stdin
def
broken_seek
(
num
):
raise
IOError
(
"
Illegal seek
"
)
fd
=
StringIO
(
b
"
foo
\n
bar
\n
"
.
decode
(
'
utf-8
'
))
fd
.
seek
=
broken_seek
sys
.
stdin
=
fd
w_list
=
WordList
(
"
-
"
)
assert
list
(
w_list
)
==
[
'
foo
'
,
'
bar
'
]
def
test_get_wordlist_ignore_empty_lines
(
self
,
tmpdir
):
def
test_get_wordlist_ignore_empty_lines
(
self
,
tmpdir
):
# we ignore empty lines in wordlists
# we ignore empty lines in wordlists
in_file
=
tmpdir
.
mkdir
(
"
work
"
).
join
(
"
mywordlist
"
)
in_file
=
tmpdir
.
mkdir
(
"
work
"
).
join
(
"
mywordlist
"
)
...
...
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