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
6c39f06a
Kaydet (Commit)
6c39f06a
authored
Eyl 16, 2009
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Remove some more boilerplate from the actual tests in test_pdb.
üst
a50d20a5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
27 deletions
+34
-27
test_pdb.py
Lib/test/test_pdb.py
+34
-27
No files found.
Lib/test/test_pdb.py
Dosyayı görüntüle @
6c39f06a
...
@@ -12,23 +12,33 @@ from test import test_support
...
@@ -12,23 +12,33 @@ from test import test_support
from
test_doctest
import
_FakeInput
from
test_doctest
import
_FakeInput
class
PdbTestInput
(
object
):
"""Context manager that makes testing Pdb in doctests easier."""
def
__init__
(
self
,
input
):
self
.
input
=
input
def
__enter__
(
self
):
self
.
real_stdin
=
sys
.
stdin
sys
.
stdin
=
_FakeInput
(
self
.
input
)
def
__exit__
(
self
,
*
exc
):
sys
.
stdin
=
self
.
real_stdin
def
test_pdb_skip_modules
():
def
test_pdb_skip_modules
():
"""This illustrates the simple case of module skipping.
"""This illustrates the simple case of module skipping.
>>> def skip_module():
>>> def skip_module():
... import string
... import string
... import pdb;pdb.Pdb(skip=['string*']).set_trace()
... import pdb;
pdb.Pdb(skip=['string*']).set_trace()
... string.lower('FOO')
... string.lower('FOO')
>>> real_stdin = sys.stdin
>>> sys.stdin = _FakeInput([
... 'step',
... 'continue',
... ])
>>> try:
>>> with PdbTestInput([
... 'step',
... 'continue'
... ]):
... skip_module()
... skip_module()
... finally:
... sys.stdin = real_stdin
> <doctest test.test_pdb.test_pdb_skip_modules[0]>(4)skip_module()
> <doctest test.test_pdb.test_pdb_skip_modules[0]>(4)skip_module()
-> string.lower('FOO')
-> string.lower('FOO')
(Pdb) step
(Pdb) step
...
@@ -36,7 +46,7 @@ def test_pdb_skip_modules():
...
@@ -36,7 +46,7 @@ def test_pdb_skip_modules():
> <doctest test.test_pdb.test_pdb_skip_modules[0]>(4)skip_module()->None
> <doctest test.test_pdb.test_pdb_skip_modules[0]>(4)skip_module()->None
-> string.lower('FOO')
-> string.lower('FOO')
(Pdb) continue
(Pdb) continue
"""
"""
# Module for testing skipping of module that makes a callback
# Module for testing skipping of module that makes a callback
...
@@ -50,22 +60,19 @@ def test_pdb_skip_modules_with_callback():
...
@@ -50,22 +60,19 @@ def test_pdb_skip_modules_with_callback():
>>> def skip_module():
>>> def skip_module():
... def callback():
... def callback():
... return None
... return None
... import pdb;pdb.Pdb(skip=['module_to_skip*']).set_trace()
... import pdb;
pdb.Pdb(skip=['module_to_skip*']).set_trace()
... mod.foo_pony(callback)
... mod.foo_pony(callback)
>>> real_stdin = sys.stdin
>>> sys.stdin = _FakeInput([
>>> with PdbTestInput([
... 'step',
... 'step',
... 'step',
... 'step',
... 'step',
... 'step',
... 'step',
... 'step',
... 'step',
... 'step',
... 'continue',
... 'continue',
... ])
... ]):
>>> try:
... skip_module()
... skip_module()
... finally:
... pass # provides something to "step" to
... sys.stdin = real_stdin
> <doctest test.test_pdb.test_pdb_skip_modules_with_callback[0]>(5)skip_module()
> <doctest test.test_pdb.test_pdb_skip_modules_with_callback[0]>(5)skip_module()
-> mod.foo_pony(callback)
-> mod.foo_pony(callback)
(Pdb) step
(Pdb) step
...
@@ -84,10 +91,10 @@ def test_pdb_skip_modules_with_callback():
...
@@ -84,10 +91,10 @@ def test_pdb_skip_modules_with_callback():
> <doctest test.test_pdb.test_pdb_skip_modules_with_callback[0]>(5)skip_module()->None
> <doctest test.test_pdb.test_pdb_skip_modules_with_callback[0]>(5)skip_module()->None
-> mod.foo_pony(callback)
-> mod.foo_pony(callback)
(Pdb) step
(Pdb) step
> <doctest test.test_pdb.test_pdb_skip_modules_with_callback[
3]>(4
)<module>()
> <doctest test.test_pdb.test_pdb_skip_modules_with_callback[
1]>(10
)<module>()
->
sys.stdin = real_stdin
->
pass # provides something to "step" to
(Pdb) continue
(Pdb) continue
"""
"""
def
test_main
():
def
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