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
d9fec15e
Kaydet (Commit)
d9fec15e
authored
Nis 29, 2013
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
refactor traceback.py to reduce code duplication (closes #17646)
Patch by Martin Morrison.
üst
0bb83f81
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
0 deletions
+28
-0
test_traceback.py
Lib/test/test_traceback.py
+28
-0
traceback.py
Lib/traceback.py
+0
-0
No files found.
Lib/test/test_traceback.py
Dosyayı görüntüle @
d9fec15e
...
...
@@ -160,11 +160,26 @@ class TracebackFormatTests(unittest.TestCase):
file_
=
StringIO
()
traceback_print
(
tb
,
file_
)
python_fmt
=
file_
.
getvalue
()
# Call all _tb and _exc functions
with
captured_output
(
"stderr"
)
as
tbstderr
:
traceback
.
print_tb
(
tb
)
tbfile
=
StringIO
()
traceback
.
print_tb
(
tb
,
file
=
tbfile
)
with
captured_output
(
"stderr"
)
as
excstderr
:
traceback
.
print_exc
()
excfmt
=
traceback
.
format_exc
()
excfile
=
StringIO
()
traceback
.
print_exc
(
file
=
excfile
)
else
:
raise
Error
(
"unable to create test traceback string"
)
# Make sure that Python and the traceback module format the same thing
self
.
assertEqual
(
traceback_fmt
,
python_fmt
)
# Now verify the _tb func output
self
.
assertEqual
(
tbstderr
.
getvalue
(),
tbfile
.
getvalue
())
# Now verify the _exc func output
self
.
assertEqual
(
excstderr
.
getvalue
(),
excfile
.
getvalue
())
self
.
assertEqual
(
excfmt
,
excfile
.
getvalue
())
# Make sure that the traceback is properly indented.
tb_lines
=
python_fmt
.
splitlines
()
...
...
@@ -174,6 +189,19 @@ class TracebackFormatTests(unittest.TestCase):
self
.
assertTrue
(
location
.
startswith
(
' File'
))
self
.
assertTrue
(
source_line
.
startswith
(
' raise'
))
def
test_stack_format
(
self
):
# Verify _stack functions. Note we have to use _getframe(1) to
# compare them without this frame appearing in the output
with
captured_output
(
"stderr"
)
as
ststderr
:
traceback
.
print_stack
(
sys
.
_getframe
(
1
))
stfile
=
StringIO
()
traceback
.
print_stack
(
sys
.
_getframe
(
1
),
file
=
stfile
)
self
.
assertEqual
(
ststderr
.
getvalue
(),
stfile
.
getvalue
())
stfmt
=
traceback
.
format_stack
(
sys
.
_getframe
(
1
))
self
.
assertEqual
(
ststderr
.
getvalue
(),
""
.
join
(
stfmt
))
cause_message
=
(
"
\n
The above exception was the direct cause "
...
...
Lib/traceback.py
Dosyayı görüntüle @
d9fec15e
This diff is collapsed.
Click to expand it.
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