def test_endElement(self): """Raise an assertion if can't find the node to end. Processes the end xml tags, according to their type. It's a method from ContentHandler class. Raises ------ AssertionError If value is not the expected. """ # Test values # Initialize a new GraphParser parser = PyGraphParser() name = 'graph' # This value changes among the results. attrs = {'xmlns': 'http://www.xces.org/ns/GrAF/1.0/'} # Is need to instance the value to the SAX type attrs = xml.sax.xmlreader.AttributesImpl(attrs) # Is need to start at least one node parser.startElement(name, attrs) # If name variable change to newname requires the graph_'newname' assert (parser.endElement(name) == parser.graph_end())
def test_graph_end(self): """Raise an assertion if can't set the tag value. Executes when the parser encounters the end graph tag. Sets the root node and adds all the edges to the graph. Neither of these tasks can be safely performed until all nodes have been added. Raises ------ AssertionError If can't set the tag value. """ # Test values # Initialize a new GraphParser parser = PyGraphParser() attrs = {'xmlns': 'http://www.xces.org/ns/GrAF/1.0/'} # Is need to instance the value to the SAX type attrs = xml.sax.xmlreader.AttributesImpl(attrs) # Initialize the annotations arrays parser.graph_start(attrs) error_message = 'Fail - Ending the graph' assert (parser.graph_end(), error_message)
def test_parse(self): """Raise an assertion if can't find a file. Return a PyGraph. Raises ------ AssertionError If the can't find the file. """ # Test values # Initialize the graph parser parser = PyGraphParser() # Change directory file = '/home/alopes/nltk_data/corpora/masc/spoken/Day3PMSession-vc.xml' assert (parser.parse(file, None))
# URL: <http://www.cidles.eu/ltll/poio> # For license information, see LICENSE.TXT """This module contains the tests to the class PyGraphParser in module PyGraphParser. This test serves to ensure the viability of the methods of the class PyGraphParser in PyGraphParser.py. """ from graf.PyDocumentHeader import PyDocumentHeader from graf.PyGraphParser import PyGraphParser import xml # Create the Graph Parser gparser = PyGraphParser() class TestPyGraphParser: """ This class contain the test methods if the class PyGraphParser. """ def test_parse(self): """Raise an assertion if can't find a file. Return a PyGraph. Raises ------ AssertionError