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
4c81d60f
Kaydet (Commit)
4c81d60f
authored
Tem 23, 2001
tarafından
Fred Drake
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Tests for the "commands" module, contributed by Nick Mathewson.
This closes SF patch #440291.
üst
15861361
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
0 deletions
+45
-0
test_commands.py
Lib/test/test_commands.py
+45
-0
No files found.
Lib/test/test_commands.py
0 → 100644
Dosyayı görüntüle @
4c81d60f
'''
Tests for commands module
Nick Mathewson
'''
import
unittest
import
os
,
tempfile
,
re
from
test_support
import
TestSkipped
,
run_unittest
from
commands
import
*
# The module says:
# "NB This only works (and is only relevant) for UNIX."
#
# Actually, getoutput should work on any platform with an os.popen, but
# I'll take the comment as given, and skip this suite.
if
os
.
name
!=
'posix'
:
raise
TestSkipped
(
'Not posix; skipping test_commands'
)
class
CommandTests
(
unittest
.
TestCase
):
def
test_getoutput
(
self
):
self
.
assertEquals
(
getoutput
(
'echo xyzzy'
),
'xyzzy'
)
self
.
assertEquals
(
getstatusoutput
(
'echo xyzzy'
),
(
0
,
'xyzzy'
))
# we use mktemp in the next line to get a filename which we
# _know_ won't exist. This is guaranteed to fail.
status
,
output
=
getstatusoutput
(
'cat '
+
tempfile
.
mktemp
())
self
.
assertNotEquals
(
status
,
0
)
def
test_getstatus
(
self
):
# This pattern should match 'ls -ld /bin/ls' on any posix
# system, however perversely configured.
pat
=
r'''-..x..x..x # It is executable.
\s+\d+ # It has some number of links.
\s+\w+\s+\w+ # It has a user and group, which may
# be named anything.
[^/]* # Skip the date.
/bin/ls # and end with the name of the file.
'''
self
.
assert_
(
re
.
match
(
pat
,
getstatus
(
"/bin/ls"
),
re
.
VERBOSE
))
run_unittest
(
CommandTests
)
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