Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
1f94efc6
Kaydet (Commit)
1f94efc6
authored
May 25, 2014
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #19925: Added tests for the spwd module. Original patch by Vajrasky Kok.
üst
62012fc7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
0 deletions
+64
-0
test_spwd.py
Lib/test/test_spwd.py
+62
-0
NEWS
Misc/NEWS
+2
-0
No files found.
Lib/test/test_spwd.py
0 → 100644
Dosyayı görüntüle @
1f94efc6
import
os
import
unittest
from
test
import
test_support
spwd
=
test_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_nam
entry
=
spwd
.
getspnam
(
random_name
)
self
.
assertIsInstance
(
entry
,
spwd
.
struct_spwd
)
self
.
assertEqual
(
entry
.
sp_nam
,
random_name
)
self
.
assertEqual
(
entry
.
sp_nam
,
entry
[
0
])
self
.
assertIsInstance
(
entry
.
sp_pwd
,
str
)
self
.
assertEqual
(
entry
.
sp_pwd
,
entry
[
1
])
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
)
if
test_support
.
have_unicode
:
try
:
unicode_name
=
unicode
(
random_name
)
except
UnicodeDecodeError
:
pass
else
:
self
.
assertEqual
(
spwd
.
getspnam
(
unicode_name
),
entry
)
def
test_main
():
test_support
.
run_unittest
(
TestSpwdRoot
)
if
__name__
==
"__main__"
:
test_main
()
Misc/NEWS
Dosyayı görüntüle @
1f94efc6
...
...
@@ -21,6 +21,8 @@ Library
Tests
-----
- Issue #19925: Added tests for the spwd module. Original patch by Vajrasky Kok.
- Issue #21522: Added Tkinter tests for Listbox.itemconfigure(),
PanedWindow.paneconfigure(), and Menu.entryconfigure().
...
...
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