Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pystache_custom
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
pystache_custom
Commits
e226768a
Commit
e226768a
authored
Apr 21, 2012
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
The test script now converts text doctest files to Python 3 when needed.
parent
e4f488c6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
3 deletions
+43
-3
.gitignore
+1
-0
pystache/tests/doctesting.py
+42
-3
No files found.
.gitignore
View file @
e226768a
*.pyc
.tox
*.temp2to3.rst
.DS_Store
# TODO: are comments allowed in .gitignore files?
# TextMate project file
...
...
pystache/tests/doctesting.py
View file @
e226768a
...
...
@@ -5,13 +5,17 @@ Exposes a get_doctests() function for the project's test harness.
"""
from
lib2to3.main
import
main
as
lib2to3main
import
doctest
import
os
import
pkgutil
import
doctest
from
shutil
import
copyfile
import
sys
import
traceback
from
pystache.tests.common
import
PACKAGE_DIR
,
TEXT_DOCTEST_PATHS
# This module follows the guidance documented here:
#
# http://docs.python.org/library/doctest.html#unittest-api
...
...
@@ -27,14 +31,19 @@ def get_doctests(text_file_dir):
(i.e. non-module files) containing doctests.
"""
suites
=
[]
# Since module_relative is False in our calls to DocFileSuite below,
# paths should be OS-specific. See the following for more info--
#
# http://docs.python.org/library/doctest.html#doctest.DocFileSuite
#
paths
=
[
os
.
path
.
normpath
(
os
.
path
.
join
(
text_file_dir
,
path
))
for
path
in
TEXT_DOCTEST_PATHS
]
py_version
=
sys
.
version_info
if
py_version
>=
(
3
,):
paths
=
_convert_paths
(
paths
)
suites
=
[]
for
path
in
paths
:
suite
=
doctest
.
DocFileSuite
(
path
,
module_relative
=
False
)
suites
.
append
(
suite
)
...
...
@@ -47,6 +56,36 @@ def get_doctests(text_file_dir):
return
suites
def
_convert_2to3
(
path
):
"""
Convert the given file, and return the path to the converted files.
"""
base
,
ext
=
os
.
path
.
splitext
(
path
)
# For example, "README.temp2to3.rst".
new_path
=
"
%
s.temp2to3
%
s"
%
(
base
,
ext
)
copyfile
(
path
,
new_path
)
args
=
[
'--doctests_only'
,
'--no-diffs'
,
'--write'
,
'--nobackups'
,
new_path
]
lib2to3main
(
"lib2to3.fixes"
,
args
=
args
)
return
new_path
def
_convert_paths
(
paths
):
"""
Convert the given files, and return the paths to the converted files.
"""
new_paths
=
[]
for
path
in
paths
:
new_path
=
_convert_2to3
(
path
)
new_paths
.
append
(
new_path
)
return
new_paths
def
_get_module_doctests
(
package_dir
):
modules
=
[]
...
...
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