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
89b49a9e
Commit
89b49a9e
authored
May 25, 2014
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Plain Diff
Issue #19925: Added tests for the spwd module. Original patch by Vajrasky Kok.
parents
a924fc7a
7df417d5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
0 deletions
+62
-0
Lib/test/test_spwd.py
Lib/test/test_spwd.py
+60
-0
Misc/NEWS
Misc/NEWS
+2
-0
No files found.
Lib/test/test_spwd.py
0 → 100644
View file @
89b49a9e
import
os
import
unittest
from
test
import
support
spwd
=
support
.
import_module
(
'spwd'
)
@
unittest
.
skipUnless
(
hasattr
(
os
,
'geteuid'
)
and
os
.
geteuid
()
==
0
,
'root privileges required'
)
class
TestSpwdRoot
(
unittest
.
TestCase
):
def
test_getspall
(
self
):
entries
=
spwd
.
getspall
()
self
.
assertIsInstance
(
entries
,
list
)
for
entry
in
entries
:
self
.
assertIsInstance
(
entry
,
spwd
.
struct_spwd
)
def
test_getspnam
(
self
):
entries
=
spwd
.
getspall
()
if
not
entries
:
self
.
skipTest
(
'empty shadow password database'
)
random_name
=
entries
[
0
].
sp_namp
entry
=
spwd
.
getspnam
(
random_name
)
self
.
assertIsInstance
(
entry
,
spwd
.
struct_spwd
)
self
.
assertEqual
(
entry
.
sp_namp
,
random_name
)
self
.
assertEqual
(
entry
.
sp_namp
,
entry
[
0
])
self
.
assertEqual
(
entry
.
sp_namp
,
entry
.
sp_nam
)
self
.
assertIsInstance
(
entry
.
sp_pwdp
,
str
)
self
.
assertEqual
(
entry
.
sp_pwdp
,
entry
[
1
])
self
.
assertEqual
(
entry
.
sp_pwdp
,
entry
.
sp_pwd
)
self
.
assertIsInstance
(
entry
.
sp_lstchg
,
int
)
self
.
assertEqual
(
entry
.
sp_lstchg
,
entry
[
2
])
self
.
assertIsInstance
(
entry
.
sp_min
,
int
)
self
.
assertEqual
(
entry
.
sp_min
,
entry
[
3
])
self
.
assertIsInstance
(
entry
.
sp_max
,
int
)
self
.
assertEqual
(
entry
.
sp_max
,
entry
[
4
])
self
.
assertIsInstance
(
entry
.
sp_warn
,
int
)
self
.
assertEqual
(
entry
.
sp_warn
,
entry
[
5
])
self
.
assertIsInstance
(
entry
.
sp_inact
,
int
)
self
.
assertEqual
(
entry
.
sp_inact
,
entry
[
6
])
self
.
assertIsInstance
(
entry
.
sp_expire
,
int
)
self
.
assertEqual
(
entry
.
sp_expire
,
entry
[
7
])
self
.
assertIsInstance
(
entry
.
sp_flag
,
int
)
self
.
assertEqual
(
entry
.
sp_flag
,
entry
[
8
])
with
self
.
assertRaises
(
KeyError
)
as
cx
:
spwd
.
getspnam
(
'invalid user name'
)
self
.
assertEqual
(
str
(
cx
.
exception
),
"'getspnam(): name not found'"
)
self
.
assertRaises
(
TypeError
,
spwd
.
getspnam
)
self
.
assertRaises
(
TypeError
,
spwd
.
getspnam
,
0
)
self
.
assertRaises
(
TypeError
,
spwd
.
getspnam
,
random_name
,
0
)
try
:
bytes_name
=
os
.
fsencode
(
random_name
)
except
UnicodeEncodeError
:
pass
else
:
self
.
assertRaises
(
TypeError
,
spwd
.
getspnam
,
bytes_name
)
if
__name__
==
"__main__"
:
unittest
.
main
()
Misc/NEWS
View file @
89b49a9e
...
...
@@ -15,6 +15,8 @@ Core and Builtins
time issue noticeable when compiling code with a large number of "and"
and "or" operators.
- Issue #19925: Added tests for the spwd module. Original patch by Vajrasky Kok.
- Issue #21418: Fix a crash in the builtin function super() when called without
argument and without current frame (ex: embedded Python).
...
...
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