In January 2021 we will introduce a 10 GB quota for project repositories. Higher limits for individual projects will be available on request. Please see https://doku.lrz.de/display/PUBLIC/GitLab for more information.

Commit 9c16b2a8 authored by di68kap's avatar di68kap

- syntaxtree.flatten_xml: now compatible with 're', not just 'regex'

- test/run.py works now without nose being installed
parent 37f225a0
...@@ -191,10 +191,14 @@ def flatten_sxpr(sxpr: str) -> str: ...@@ -191,10 +191,14 @@ def flatten_sxpr(sxpr: str) -> str:
def flatten_xml(xml: str) -> str: def flatten_xml(xml: str) -> str:
"""Returns an XML-tree as a one linter without unnecessary whitespace, """Returns an XML-tree as a one liner without unnecessary whitespace,
i.e. only whitespace within leaf-nodes is preserved. i.e. only whitespace within leaf-nodes is preserved.
""" """
return re.sub(r'\s+(?=<\w)', '', re.sub(r'(?<=</\w+>)\s+', '', xml)) # works only with regex
# return re.sub(r'\s+(?=<\w)', '', re.sub(r'(?<=</\w+>)\s+', '', xml))
def tag_only(m):
return m.groupdict()['closing_tag']
return re.sub(r'\s+(?=<\w)', '', re.sub(r'(?P<closing_tag></\w+>)\s+', tag_only, xml))
class Node(collections.abc.Sized): class Node(collections.abc.Sized):
......
...@@ -3,7 +3,19 @@ ...@@ -3,7 +3,19 @@
if __name__ == "__main__": if __name__ == "__main__":
import os import os
if os.getcwd().endswith('test'): # if os.getcwd().endswith('test'):
os.chdir('..') # os.chdir('..')
print("Running nosetests:") # print("Running nosetests:")
os.system("nosetests test") # os.system("nosetests test")
interpreter = 'python '
# interpreter = r'C:\Users\di68kap\AppData\Local\Programs\Python\Python37-32\python.exe '
os.system(interpreter + '--version')
assert os.getcwd().endswith('test')
files = os.listdir()
for filename in files:
if filename.startswith('test_'):
print('\nTEST ' + filename)
os.system(interpreter + filename)
...@@ -451,4 +451,4 @@ class TestAllSome: ...@@ -451,4 +451,4 @@ class TestAllSome:
if __name__ == "__main__": if __name__ == "__main__":
from DHParser.testing import runner from DHParser.testing import runner
runner("TestTermBug", globals()) runner("", globals())
...@@ -59,6 +59,11 @@ class TestParseXML: ...@@ -59,6 +59,11 @@ class TestParseXML:
tree = parse_xml(' <a> <b>beta</b> </a> ') tree = parse_xml(' <a> <b>beta</b> </a> ')
assert flatten_xml(tree.as_xml()) == '<a><b>beta</b></a>' assert flatten_xml(tree.as_xml()) == '<a><b>beta</b></a>'
def test_flatten_xml(self):
tree = parse_xml('<alpha>\n <beta>gamma</beta>\n</alpha>')
flat_xml = flatten_xml(tree.as_xml())
assert flat_xml == '<alpha><beta>gamma</beta></alpha>', flat_xml
class TestNode: class TestNode:
""" """
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment