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
f41ffeda
Kaydet (Commit)
f41ffeda
authored
May 19, 2013
tarafından
Antoine Pitrou
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #11995: test_pydoc doesn't import all sys.path modules anymore.
üst
bb6b51ca
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
8 deletions
+55
-8
test_pydoc.py
Lib/test/test_pydoc.py
+49
-8
NEWS
Misc/NEWS
+6
-0
No files found.
Lib/test/test_pydoc.py
Dosyayı görüntüle @
f41ffeda
...
@@ -4,15 +4,17 @@ import difflib
...
@@ -4,15 +4,17 @@ import difflib
import
__builtin__
import
__builtin__
import
re
import
re
import
pydoc
import
pydoc
import
contextlib
import
inspect
import
inspect
import
keyword
import
keyword
import
pkgutil
import
unittest
import
unittest
import
xml.etree
import
xml.etree
import
test.test_support
import
test.test_support
from
collections
import
namedtuple
from
collections
import
namedtuple
from
test.script_helper
import
assert_python_ok
from
test.script_helper
import
assert_python_ok
from
test.test_support
import
(
from
test.test_support
import
(
TESTFN
,
rmtree
,
reap_children
,
captured_stdout
)
TESTFN
,
rmtree
,
reap_children
,
captured_stdout
,
captured_stderr
)
from
test
import
pydoc_mod
from
test
import
pydoc_mod
...
@@ -228,7 +230,30 @@ def print_diffs(text1, text2):
...
@@ -228,7 +230,30 @@ def print_diffs(text1, text2):
print
'
\n
'
+
''
.
join
(
diffs
)
print
'
\n
'
+
''
.
join
(
diffs
)
class
PyDocDocTest
(
unittest
.
TestCase
):
class
PydocBaseTest
(
unittest
.
TestCase
):
def
_restricted_walk_packages
(
self
,
walk_packages
,
path
=
None
):
"""
A version of pkgutil.walk_packages() that will restrict itself to
a given path.
"""
default_path
=
path
or
[
os
.
path
.
dirname
(
__file__
)]
def
wrapper
(
path
=
None
,
prefix
=
''
,
onerror
=
None
):
return
walk_packages
(
path
or
default_path
,
prefix
,
onerror
)
return
wrapper
@contextlib.contextmanager
def
restrict_walk_packages
(
self
,
path
=
None
):
walk_packages
=
pkgutil
.
walk_packages
pkgutil
.
walk_packages
=
self
.
_restricted_walk_packages
(
walk_packages
,
path
)
try
:
yield
finally
:
pkgutil
.
walk_packages
=
walk_packages
class
PydocDocTest
(
unittest
.
TestCase
):
@unittest.skipIf
(
sys
.
flags
.
optimize
>=
2
,
@unittest.skipIf
(
sys
.
flags
.
optimize
>=
2
,
"Docstrings are omitted with -O2 and above"
)
"Docstrings are omitted with -O2 and above"
)
...
@@ -303,7 +328,7 @@ class PyDocDocTest(unittest.TestCase):
...
@@ -303,7 +328,7 @@ class PyDocDocTest(unittest.TestCase):
"<type 'exceptions.Exception'>"
)
"<type 'exceptions.Exception'>"
)
class
PydocImportTest
(
unittest
.
TestCase
):
class
PydocImportTest
(
PydocBaseTest
):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
test_dir
=
os
.
mkdir
(
TESTFN
)
self
.
test_dir
=
os
.
mkdir
(
TESTFN
)
...
@@ -338,8 +363,19 @@ class PydocImportTest(unittest.TestCase):
...
@@ -338,8 +363,19 @@ class PydocImportTest(unittest.TestCase):
badsyntax
=
os
.
path
.
join
(
pkgdir
,
"__init__"
)
+
os
.
extsep
+
"py"
badsyntax
=
os
.
path
.
join
(
pkgdir
,
"__init__"
)
+
os
.
extsep
+
"py"
with
open
(
badsyntax
,
'w'
)
as
f
:
with
open
(
badsyntax
,
'w'
)
as
f
:
f
.
write
(
"invalid python syntax = $1
\n
"
)
f
.
write
(
"invalid python syntax = $1
\n
"
)
result
=
run_pydoc
(
'zqwykjv'
,
'-k'
,
PYTHONPATH
=
TESTFN
)
with
self
.
restrict_walk_packages
(
path
=
[
TESTFN
]):
self
.
assertEqual
(
''
,
result
)
with
captured_stdout
()
as
out
:
with
captured_stderr
()
as
err
:
pydoc
.
apropos
(
'xyzzy'
)
# No result, no error
self
.
assertEqual
(
out
.
getvalue
(),
''
)
self
.
assertEqual
(
err
.
getvalue
(),
''
)
# The package name is still matched
with
captured_stdout
()
as
out
:
with
captured_stderr
()
as
err
:
pydoc
.
apropos
(
'syntaxerr'
)
self
.
assertEqual
(
out
.
getvalue
()
.
strip
(),
'syntaxerr'
)
self
.
assertEqual
(
err
.
getvalue
(),
''
)
def
test_apropos_with_unreadable_dir
(
self
):
def
test_apropos_with_unreadable_dir
(
self
):
# Issue 7367 - pydoc -k failed when unreadable dir on path
# Issue 7367 - pydoc -k failed when unreadable dir on path
...
@@ -348,8 +384,13 @@ class PydocImportTest(unittest.TestCase):
...
@@ -348,8 +384,13 @@ class PydocImportTest(unittest.TestCase):
self
.
addCleanup
(
os
.
rmdir
,
self
.
unreadable_dir
)
self
.
addCleanup
(
os
.
rmdir
,
self
.
unreadable_dir
)
# Note, on Windows the directory appears to be still
# Note, on Windows the directory appears to be still
# readable so this is not really testing the issue there
# readable so this is not really testing the issue there
result
=
run_pydoc
(
'zqwykjv'
,
'-k'
,
PYTHONPATH
=
TESTFN
)
with
self
.
restrict_walk_packages
(
path
=
[
TESTFN
]):
self
.
assertEqual
(
''
,
result
)
with
captured_stdout
()
as
out
:
with
captured_stderr
()
as
err
:
pydoc
.
apropos
(
'SOMEKEY'
)
# No result, no error
self
.
assertEqual
(
out
.
getvalue
(),
''
)
self
.
assertEqual
(
err
.
getvalue
(),
''
)
class
TestDescriptions
(
unittest
.
TestCase
):
class
TestDescriptions
(
unittest
.
TestCase
):
...
@@ -412,7 +453,7 @@ class TestHelper(unittest.TestCase):
...
@@ -412,7 +453,7 @@ class TestHelper(unittest.TestCase):
def
test_main
():
def
test_main
():
try
:
try
:
test
.
test_support
.
run_unittest
(
Py
D
ocDocTest
,
test
.
test_support
.
run_unittest
(
Py
d
ocDocTest
,
PydocImportTest
,
PydocImportTest
,
TestDescriptions
,
TestDescriptions
,
TestHelper
)
TestHelper
)
...
...
Misc/NEWS
Dosyayı görüntüle @
f41ffeda
...
@@ -18,6 +18,12 @@ Library
...
@@ -18,6 +18,12 @@ Library
- Fix typos in the multiprocessing module.
- Fix typos in the multiprocessing module.
Tests
-----
- Issue #11995: test_pydoc doesn'
t
import
all
sys
.
path
modules
anymore
.
What
's New in Python 2.7.5?
What
's New in Python 2.7.5?
===========================
===========================
...
...
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