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
add0ccc2
Kaydet (Commit)
add0ccc2
authored
Şub 27, 2003
tarafından
Skip Montanaro
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
simple test case for dis module
üst
68468eba
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
0 deletions
+53
-0
test_dis.py
Lib/test/test_dis.py
+53
-0
No files found.
Lib/test/test_dis.py
0 → 100644
Dosyayı görüntüle @
add0ccc2
from
test.test_support
import
verify
,
verbose
,
TestFailed
,
run_unittest
import
sys
import
dis
import
StringIO
# Minimal tests for dis module
import
unittest
# placement is crucial!!! move the start of _f and you have to adjust the
# line numbers in dis_f
def
_f
(
a
):
print
a
return
1
dis_f
=
"""
\
13 0 LOAD_FAST 0 (a)
3 PRINT_ITEM
4 PRINT_NEWLINE
14 5 LOAD_CONST 1 (1)
8 RETURN_VALUE
9 LOAD_CONST 0 (None)
12 RETURN_VALUE
"""
class
DisTests
(
unittest
.
TestCase
):
def
test_opmap
(
self
):
self
.
assertEqual
(
dis
.
opmap
[
"STOP_CODE"
],
0
)
self
.
assertEqual
(
dis
.
opmap
[
"LOAD_CONST"
]
in
dis
.
hasconst
,
True
)
self
.
assertEqual
(
dis
.
opmap
[
"STORE_NAME"
]
in
dis
.
hasname
,
True
)
def
test_opname
(
self
):
self
.
assertEqual
(
dis
.
opname
[
dis
.
opmap
[
"LOAD_FAST"
]],
"LOAD_FAST"
)
def
test_boundaries
(
self
):
self
.
assertEqual
(
dis
.
opmap
[
"EXTENDED_ARG"
],
dis
.
EXTENDED_ARG
)
self
.
assertEqual
(
dis
.
opmap
[
"STORE_NAME"
],
dis
.
HAVE_ARGUMENT
)
def
test_dis
(
self
):
s
=
StringIO
.
StringIO
()
save_stdout
=
sys
.
stdout
sys
.
stdout
=
s
dis
.
dis
(
_f
)
sys
.
stdout
=
save_stdout
self
.
assertEqual
(
dis_f
,
s
.
getvalue
())
def
test_main
():
run_unittest
(
DisTests
)
if
__name__
==
"__main__"
:
test_main
()
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