Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
9.2.2023: Due to updates GitLab will be unavailable for some minutes between 9:00 and 11:00.
Open sidebar
badw-it
DHParser
Commits
41d7b210
Commit
41d7b210
authored
Aug 20, 2018
by
eckhart
Browse files
test/run.py now also runs all doctests
parent
9760c373
Changes
2
Hide whitespace changes
Inline
Side-by-side
DHParser/transform.py
View file @
41d7b210
...
...
@@ -34,7 +34,7 @@ from functools import partial, reduce, singledispatch
from
DHParser.error
import
Error
from
DHParser.syntaxtree
import
Node
,
WHITESPACE_PTYPE
,
TOKEN_PTYPE
,
ParserBase
,
MockParser
,
\
ZOMBIE_NODE
ZOMBIE_NODE
,
parse_sxpr
,
flatten_sxpr
from
DHParser.toolkit
import
issubtype
,
isgenerictype
,
expand_table
,
smart_list
,
re
,
typing
from
typing
import
AbstractSet
,
Any
,
ByteString
,
Callable
,
cast
,
Container
,
Dict
,
\
Tuple
,
List
,
Sequence
,
Union
,
Text
,
Generic
...
...
@@ -669,7 +669,7 @@ def collapse_if(context: List[Node], condition: Callable, target_tag: ParserBase
>>> text = MockParser('text')
>>> collapse_if([tree], not_one_of({'superscript', 'subscript'}), text)
>>> print(flatten_sxpr(tree.as_sxpr()))
(place (text "p.
26") (superscript "b") (text ",18"))
(place (text "p.26") (superscript "b") (text ",18"))
See `test_transform.TestComplexTransformations` for examples.
"""
...
...
test/run.py
View file @
41d7b210
...
...
@@ -38,8 +38,10 @@ if __name__ == "__main__":
os
.
chdir
(
'..'
)
files
=
os
.
listdir
(
'DHParser'
)
for
filename
in
files
:
if
filename
.
endswith
(
'.py'
):
print
(
'
\n
DOCTESTS in '
+
filename
)
os
.
system
(
interpreter
+
' -m doctest '
+
filename
)
if
filename
.
endswith
(
'.py'
)
and
filename
\
not
in
[
"foreign_typing.py"
,
"stringview.py"
,
"__init__.py"
]:
filepath
=
os
.
path
.
join
(
'DHParser'
,
filename
)
print
(
'
\n
DOCTESTS in '
+
filepath
)
os
.
system
(
interpreter
+
' -m doctest '
+
filepath
)
os
.
chdir
(
cwd
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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