from rdflib import Graph, Namespace, URIRef, Literal
from rdflib.compare import to_isomorphic
import unittest


class TestIssue655(unittest.TestCase):

    def test_issue655(self):
        PROV = Namespace('http://www.w3.org/ns/prov#')

        bob = URIRef("http://example.org/object/Bob")
        value = Literal(float("inf"))

        # g1 is a simple graph with one attribute having an infinite value
        g1 = Graph()
        g1.add((bob, PROV.value, value))

        # Build g2 out of the deserialisation of g1 serialisation
        g2 = Graph()
        g2.parse(data=g1.serialize(format='turtle'), format='turtle')

        self.assertTrue(g1.serialize(
            format='turtle') == g2.serialize(format='turtle'))
        self.assertTrue(to_isomorphic(g1) == to_isomorphic(g2))

if __name__ == "__main__":
    unittest.main()

from rdflib import Graph, Namespace, URIRef, Literal
from rdflib.compare import to_isomorphic
import unittest


class TestIssue655(unittest.TestCase):

    def test_issue655(self):
        PROV = Namespace('http://www.w3.org/ns/prov#')

        bob = URIRef("http://example.org/object/Bob")
        value = Literal(float("inf"))

        # g1 is a simple graph with one attribute having an infinite value
        g1 = Graph()
        g1.add((bob, PROV.value, value))

        # Build g2 out of the deserialisation of g1 serialisation
        g2 = Graph()
        g2.parse(data=g1.serialize(format='turtle'), format='turtle')

        self.assertTrue(g1.serialize(
            format='turtle') == g2.serialize(format='turtle'))
        self.assertTrue(to_isomorphic(g1) == to_isomorphic(g2))

        self.assertTrue(Literal(float("inf")).n3().split("^")[0] == '"INF"')
        self.assertTrue(Literal(float("-inf")).n3().split("^")[0] == '"-INF"')
if __name__ == "__main__":
    unittest.main()

Add tests requested by @joernhees
Add tests requested by @joernhees

  from rdflib import Graph, Namespace, URIRef, Literal
  from rdflib.compare import to_isomorphic
  import unittest
  
  
  class TestIssue655(unittest.TestCase):
  
      def test_issue655(self):
          PROV = Namespace('http://www.w3.org/ns/prov#')
  
          bob = URIRef("http://example.org/object/Bob")
          value = Literal(float("inf"))
  
          # g1 is a simple graph with one attribute having an infinite value
          g1 = Graph()
          g1.add((bob, PROV.value, value))
  
          # Build g2 out of the deserialisation of g1 serialisation
          g2 = Graph()
          g2.parse(data=g1.serialize(format='turtle'), format='turtle')
  
          self.assertTrue(g1.serialize(
              format='turtle') == g2.serialize(format='turtle'))
          self.assertTrue(to_isomorphic(g1) == to_isomorphic(g2))
  
+         self.assertTrue(Literal(float("inf")).n3().split("^")[0] == '"INF"')
+         self.assertTrue(Literal(float("-inf")).n3().split("^")[0] == '"-INF"')
  if __name__ == "__main__":
      unittest.main()
  
Add tests requested by @joernhees
## Code Before:
from rdflib import Graph, Namespace, URIRef, Literal
from rdflib.compare import to_isomorphic
import unittest


class TestIssue655(unittest.TestCase):

    def test_issue655(self):
        PROV = Namespace('http://www.w3.org/ns/prov#')

        bob = URIRef("http://example.org/object/Bob")
        value = Literal(float("inf"))

        # g1 is a simple graph with one attribute having an infinite value
        g1 = Graph()
        g1.add((bob, PROV.value, value))

        # Build g2 out of the deserialisation of g1 serialisation
        g2 = Graph()
        g2.parse(data=g1.serialize(format='turtle'), format='turtle')

        self.assertTrue(g1.serialize(
            format='turtle') == g2.serialize(format='turtle'))
        self.assertTrue(to_isomorphic(g1) == to_isomorphic(g2))

if __name__ == "__main__":
    unittest.main()

## Instruction:
Add tests requested by @joernhees
## Code After:
from rdflib import Graph, Namespace, URIRef, Literal
from rdflib.compare import to_isomorphic
import unittest


class TestIssue655(unittest.TestCase):

    def test_issue655(self):
        PROV = Namespace('http://www.w3.org/ns/prov#')

        bob = URIRef("http://example.org/object/Bob")
        value = Literal(float("inf"))

        # g1 is a simple graph with one attribute having an infinite value
        g1 = Graph()
        g1.add((bob, PROV.value, value))

        # Build g2 out of the deserialisation of g1 serialisation
        g2 = Graph()
        g2.parse(data=g1.serialize(format='turtle'), format='turtle')

        self.assertTrue(g1.serialize(
            format='turtle') == g2.serialize(format='turtle'))
        self.assertTrue(to_isomorphic(g1) == to_isomorphic(g2))

        self.assertTrue(Literal(float("inf")).n3().split("^")[0] == '"INF"')
        self.assertTrue(Literal(float("-inf")).n3().split("^")[0] == '"-INF"')
if __name__ == "__main__":
    unittest.main()
