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
d3a81df1
Kaydet (Commit)
d3a81df1
authored
Kas 21, 2007
tarafından
Brett Cannon
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Backport of r59082 (doctest and using __loader__.get_data()).
üst
946a51c1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
1 deletion
+24
-1
doctest.py
Lib/doctest.py
+4
-1
test_doctest.py
Lib/test/test_doctest.py
+18
-0
NEWS
Misc/NEWS
+2
-0
No files found.
Lib/doctest.py
Dosyayı görüntüle @
d3a81df1
...
...
@@ -209,7 +209,10 @@ def _load_testfile(filename, package, module_relative):
filename
=
_module_relative_path
(
package
,
filename
)
if
hasattr
(
package
,
'__loader__'
):
if
hasattr
(
package
.
__loader__
,
'get_data'
):
return
package
.
__loader__
.
get_data
(
filename
),
filename
file_contents
=
package
.
__loader__
.
get_data
(
filename
)
# get_data() opens files as 'rb', so one must do the equivalent
# conversion as universal newlines would do.
return
file_contents
.
replace
(
os
.
linesep
,
'
\n
'
),
filename
return
open
(
filename
)
.
read
(),
filename
def
_indent
(
s
,
indent
=
4
):
...
...
Lib/test/test_doctest.py
Dosyayı görüntüle @
d3a81df1
...
...
@@ -1908,6 +1908,24 @@ def test_DocFileSuite():
>>> suite.run(unittest.TestResult())
<unittest.TestResult run=3 errors=0 failures=3>
Support for using a package's __loader__.get_data() is also
provided.
>>> import unittest, pkgutil, test
>>> if not hasattr(test, '__loader__'):
... test.__loader__ = pkgutil.get_loader(test)
... added_loader = True
>>> try:
... suite = doctest.DocFileSuite('test_doctest.txt',
... 'test_doctest2.txt',
... 'test_doctest4.txt',
... package='test')
... suite.run(unittest.TestResult())
... finally:
... if added_loader:
... del test.__loader__
<unittest.TestResult run=3 errors=0 failures=3>
'/' should be used as a path separator. It will be converted
to a native separator at run time:
...
...
Misc/NEWS
Dosyayı görüntüle @
d3a81df1
...
...
@@ -38,6 +38,8 @@ Core and builtins
Library
-------
- doctest mis-used __loader__.get_data(), assuming universal newlines was used.
- Issue #1705170: contextlib.contextmanager was still swallowing
StopIteration in some cases. This should no longer happen.
...
...
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