def test2(self):
     lit = Literal("\tBeing a Doctor Is\n\ta Full-Time Job\r",
                   datatype=XSD.normalizedString)
     st = Literal(" Being a Doctor Is  a Full-Time Job ",
                  datatype=XSD.string)
     self.assertFalse(Literal.eq(st, lit))
     self.assertEqual(str(lit), str(st))
Exemple #2
0
def testHTML():

    l1 = Literal("<msg>hello</msg>", datatype=RDF.XMLLiteral)
    assert l1.value is not None, "xml must have been parsed"
    assert l1.datatype == RDF.XMLLiteral, "literal must have right datatype"

    l2 = Literal("<msg>hello</msg>", datatype=RDF.HTML)
    assert l2.value is not None, "xml must have been parsed"
    assert l2.datatype == RDF.HTML, "literal must have right datatype"

    assert l1 != l2
    assert not l1.eq(l2)
Exemple #3
0
def testHTML():
    
    l1=Literal('<msg>hello</msg>', datatype=RDF.XMLLiteral)
    assert l1.value is not None, 'xml must have been parsed'
    assert l1.datatype==RDF.XMLLiteral, 'literal must have right datatype'

    l2=Literal('<msg>hello</msg>', datatype=RDF.HTML)
    assert l2.value is not None, 'xml must have been parsed'
    assert l2.datatype==RDF.HTML, 'literal must have right datatype'

    assert l1!=l2
    assert not l1.eq(l2)
Exemple #4
0
def testPythonRoundtrip():
    l1 = Literal("<msg>hello</msg>", datatype=RDF.XMLLiteral)
    assert l1.value is not None, "xml must have been parsed"
    assert l1.datatype == RDF.XMLLiteral, "literal must have right datatype"

    l2 = Literal("<msg>good morning</msg>", datatype=RDF.XMLLiteral)
    assert l2.value is not None, "xml must have been parsed"
    assert not l1.eq(l2), "literals must NOT be equal"

    l3 = Literal(l1.value)
    assert l1.eq(l3), "roundtripped literals must be equal"
    assert l3.datatype == RDF.XMLLiteral, "literal must have right datatype"

    l4 = Literal("<msg >hello</msg>", datatype=RDF.XMLLiteral)
    assert l1 == l4
    assert l1.eq(l4)

    rdflib.NORMALIZE_LITERALS = False
    l4 = Literal("<msg >hello</msg>", datatype=RDF.XMLLiteral)
    assert l1 != l4
    assert l1.eq(l4)
    rdflib.NORMALIZE_LITERALS = True
def testPythonRoundtrip(): 
    l1=Literal('<msg>hello</msg>', datatype=RDF.XMLLiteral)
    assert l1.value is not None, 'xml must have been parsed'
    assert l1.datatype==RDF.XMLLiteral, 'literal must have right datatype'

    l2=Literal('<msg>good morning</msg>', datatype=RDF.XMLLiteral)
    assert l2.value is not None, 'xml must have been parsed'
    assert not l1.eq(l2), 'literals must NOT be equal'    

    l3=Literal(l1.value)
    assert l1.eq(l3), 'roundtripped literals must be equal'
    assert l3.datatype==RDF.XMLLiteral, 'literal must have right datatype'

    l4=Literal('<msg >hello</msg>', datatype=RDF.XMLLiteral)
    assert l1==l4
    assert l1.eq(l4)

    rdflib.NORMALIZE_LITERALS=False
    l4=Literal('<msg >hello</msg>', datatype=RDF.XMLLiteral)
    assert l1!=l4
    assert l1.eq(l4)
    rdflib.NORMALIZE_LITERALS=True