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
b72ad88d
Commit
b72ad88d
authored
9 years ago
by
ulif
Browse files
Options
Downloads
Patches
Plain Diff
More test with open fds and WordList.
Make sure WordLists handle open file descriptors correctly.
parent
03ec0150
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_wordlist.py
+18
-0
18 additions, 0 deletions
tests/test_wordlist.py
with
18 additions
and
0 deletions
tests/test_wordlist.py
+
18
−
0
View file @
b72ad88d
...
...
@@ -219,6 +219,24 @@ class TestWordList(object):
assert
w_list
.
fd
is
not
None
assert
w_list
.
path
is
None
def
test_open_file_descriptor_simple
(
self
,
tmpdir
):
# we handle simple lists from open file descriptors correctly
in_file
=
tmpdir
.
mkdir
(
"
work
"
).
join
(
"
mywordlist
"
)
in_file
.
write
(
"
foo
\n
bar
\n\n
baz
\n
"
)
with
open
(
str
(
in_file
),
"
r
"
)
as
my_open_file
:
w_list
=
WordList
(
my_open_file
)
result
=
tuple
(
w_list
)
assert
result
==
(
"
foo
"
,
"
bar
"
,
"
baz
"
)
def
test_open_file_descriptor_signed
(
self
):
# we can handle signed wordlists from open file descriptors
in_path
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
"
sample_signed_wordlist.asc
"
)
with
open
(
str
(
in_path
),
"
r
"
)
as
my_open_file
:
w_list
=
WordList
(
my_open_file
)
result
=
tuple
(
w_list
)
assert
(
"
foo
"
,
"
bar
"
,
"
-dash-at-start
"
,
"
baz
"
)
==
result
def
test_detect_unsigned_wordlists
(
self
,
tmpdir
):
# we can detect unsigned wordlist files.
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