mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2026-09-03 20:52:55 -05:00
Fixed the coverage extension test as well as the coverage extension itself for python3
This commit is contained in:
@@ -173,8 +173,11 @@ class CoverageBuilder(Builder):
|
|||||||
|
|
||||||
attrs = []
|
attrs = []
|
||||||
|
|
||||||
|
for attr_name in dir(obj):
|
||||||
|
attr = getattr(obj, attr_name)
|
||||||
for attr_name, attr in inspect.getmembers(
|
for attr_name, attr in inspect.getmembers(
|
||||||
obj, inspect.ismethod):
|
obj, lambda x: inspect.ismethod(x) or \
|
||||||
|
inspect.isfunction(x)):
|
||||||
if attr_name[0] == '_':
|
if attr_name[0] == '_':
|
||||||
# starts with an underscore, ignore it
|
# starts with an underscore, ignore it
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -142,6 +142,33 @@ class path(str):
|
|||||||
finally:
|
finally:
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
|
def bytes(self):
|
||||||
|
"""
|
||||||
|
Returns the bytes in the file.
|
||||||
|
"""
|
||||||
|
f = open(self, mode='rb')
|
||||||
|
try:
|
||||||
|
return f.read()
|
||||||
|
finally:
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
def write_bytes(self, bytes, append=False):
|
||||||
|
"""
|
||||||
|
Writes the given `bytes` to the file.
|
||||||
|
|
||||||
|
:param append:
|
||||||
|
If ``True`` given `bytes` are added at the end of the file.
|
||||||
|
"""
|
||||||
|
if append:
|
||||||
|
mode = 'ab'
|
||||||
|
else:
|
||||||
|
mode = 'wb'
|
||||||
|
f = open(self, mode=mode)
|
||||||
|
try:
|
||||||
|
f.write(bytes)
|
||||||
|
finally:
|
||||||
|
f.close()
|
||||||
|
|
||||||
def exists(self):
|
def exists(self):
|
||||||
"""
|
"""
|
||||||
Returns ``True`` if the path exist.
|
Returns ``True`` if the path exist.
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ def test_build(app):
|
|||||||
assert 'api.h' in c_undoc
|
assert 'api.h' in c_undoc
|
||||||
assert ' * Py_SphinxTest' in c_undoc
|
assert ' * Py_SphinxTest' in c_undoc
|
||||||
|
|
||||||
undoc_py, undoc_c = pickle.loads((app.outdir / 'undoc.pickle').text())
|
undoc_py, undoc_c = pickle.loads((app.outdir / 'undoc.pickle').bytes())
|
||||||
assert len(undoc_c) == 1
|
assert len(undoc_c) == 1
|
||||||
# the key is the full path to the header file, which isn't testable
|
# the key is the full path to the header file, which isn't testable
|
||||||
assert undoc_c.values()[0] == [('function', 'Py_SphinxTest')]
|
assert undoc_c.values()[0] == [('function', 'Py_SphinxTest')]
|
||||||
|
|||||||
Reference in New Issue
Block a user