Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
243a73de
Commit
243a73de
authored
Aug 13, 2019
by
shireenrao
Committed by
Steve Dower
Aug 13, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-25172: Add test for crypt ImportError on Windows (GH-15252)
parent
82642a05
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
7 deletions
+28
-7
Lib/test/test_crypt.py
Lib/test/test_crypt.py
+28
-7
No files found.
Lib/test/test_crypt.py
View file @
243a73de
import
sys
from
test
import
support
import
unittest
crypt
=
support
.
import_module
(
'crypt'
)
try
:
import
crypt
IMPORT_ERROR
=
None
except
ImportError
as
ex
:
crypt
=
None
IMPORT_ERROR
=
str
(
ex
)
@
unittest
.
skipIf
(
crypt
,
'This should only run on windows'
)
class
TestWhyCryptDidNotImport
(
unittest
.
TestCase
):
def
test_failure_only_for_windows
(
self
):
self
.
assertEqual
(
sys
.
platform
,
'win32'
)
def
test_import_failure_message
(
self
):
self
.
assertIn
(
'not supported'
,
IMPORT_ERROR
)
@
unittest
.
skipUnless
(
crypt
,
'Not supported on Windows'
)
class
CryptTestCase
(
unittest
.
TestCase
):
def
test_crypt
(
self
):
...
...
@@ -39,9 +55,13 @@ class CryptTestCase(unittest.TestCase):
else
:
self
.
assertEqual
(
crypt
.
methods
[
-
1
],
crypt
.
METHOD_CRYPT
)
@
unittest
.
skipUnless
(
crypt
.
METHOD_SHA256
in
crypt
.
methods
or
crypt
.
METHOD_SHA512
in
crypt
.
methods
,
'requires support of SHA-2'
)
@
unittest
.
skipUnless
(
crypt
and
(
crypt
.
METHOD_SHA256
in
crypt
.
methods
or
crypt
.
METHOD_SHA512
in
crypt
.
methods
),
'requires support of SHA-2'
,
)
def
test_sha2_rounds
(
self
):
for
method
in
(
crypt
.
METHOD_SHA256
,
crypt
.
METHOD_SHA512
):
for
rounds
in
1000
,
10_000
,
100_000
:
...
...
@@ -54,8 +74,9 @@ class CryptTestCase(unittest.TestCase):
cr2
=
crypt
.
crypt
(
'mypassword'
,
cr
)
self
.
assertEqual
(
cr2
,
cr
)
@
unittest
.
skipUnless
(
crypt
.
METHOD_BLOWFISH
in
crypt
.
methods
,
'requires support of Blowfish'
)
@
unittest
.
skipUnless
(
crypt
and
crypt
.
METHOD_BLOWFISH
in
crypt
.
methods
,
'requires support of Blowfish'
)
def
test_blowfish_rounds
(
self
):
for
log_rounds
in
range
(
4
,
11
):
salt
=
crypt
.
mksalt
(
crypt
.
METHOD_BLOWFISH
,
rounds
=
1
<<
log_rounds
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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