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
f1c42538
Kaydet (Commit)
f1c42538
authored
Nis 11, 2013
tarafından
R David Murray
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
#17699: Fix the new getpass test failures on windows.
Patch by Zachary Ware.
üst
eae41af3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
12 deletions
+25
-12
test_getpass.py
Lib/test/test_getpass.py
+25
-12
No files found.
Lib/test/test_getpass.py
Dosyayı görüntüle @
f1c42538
import
getpass
import
os
import
termios
import
unittest
from
io
import
StringIO
from
unittest
import
mock
from
test
import
support
try
:
import
termios
except
ImportError
:
termios
=
None
try
:
import
pwd
except
ImportError
:
pwd
=
None
@mock.patch
(
'os.environ'
)
class
GetpassGetuserTest
(
unittest
.
TestCase
):
...
...
@@ -16,7 +24,10 @@ class GetpassGetuserTest(unittest.TestCase):
def
test_username_priorities_of_env_values
(
self
,
environ
):
environ
.
get
.
return_value
=
None
getpass
.
getuser
()
try
:
getpass
.
getuser
()
except
ImportError
:
# in case there's no pwd module
pass
self
.
assertEqual
(
environ
.
get
.
call_args_list
,
[
mock
.
call
(
x
)
for
x
in
(
'LOGNAME'
,
'USER'
,
'LNAME'
,
'USERNAME'
)])
...
...
@@ -24,13 +35,16 @@ class GetpassGetuserTest(unittest.TestCase):
def
test_username_falls_back_to_pwd
(
self
,
environ
):
expected_name
=
'some_name'
environ
.
get
.
return_value
=
None
with
mock
.
patch
(
'os.getuid'
)
as
uid
,
\
mock
.
patch
(
'pwd.getpwuid'
)
as
getpw
:
uid
.
return_value
=
42
getpw
.
return_value
=
[
expected_name
]
self
.
assertEqual
(
expected_name
,
getpass
.
getuser
())
getpw
.
assert_called_once_with
(
42
)
if
pwd
:
with
mock
.
patch
(
'os.getuid'
)
as
uid
,
\
mock
.
patch
(
'pwd.getpwuid'
)
as
getpw
:
uid
.
return_value
=
42
getpw
.
return_value
=
[
expected_name
]
self
.
assertEqual
(
expected_name
,
getpass
.
getuser
())
getpw
.
assert_called_once_with
(
42
)
else
:
self
.
assertRaises
(
ImportError
,
getpass
.
getuser
)
class
GetpassRawinputTest
(
unittest
.
TestCase
):
...
...
@@ -68,9 +82,8 @@ class GetpassRawinputTest(unittest.TestCase):
# the password input be taken directly from the tty, and that it not be echoed
# on the screen, unless we are falling back to stderr/stdin.
# Some of these might run on other platforms, but play it safe.
@unittest.skipUnless
(
os
.
name
==
'posix'
,
'tests are for the unix version of getpass'
)
# Some of these might run on platforms without termios, but play it safe.
@unittest.skipUnless
(
termios
,
'tests require system with termios'
)
class
UnixGetpassTest
(
unittest
.
TestCase
):
def
test_uses_tty_directly
(
self
):
...
...
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