Exemplo n.º 1
0
    def test_io(self):
        gs = GraphSet()
        st = gs.dumps()
        self.assertEqual(st, "B\n.\n")
        gs = GraphSet.loads(st)
        self.assertEqual(gs, GraphSet())

        gs = GraphSet([g0])
        st = gs.dumps()
        self.assertEqual(st, "T\n.\n")
        gs = GraphSet.loads(st)
        self.assertEqual(gs, GraphSet([g0]))

        v = [g0, g1, g12, g123, g1234, g134, g14, g4]
        gs = GraphSet(v)
        st = gs.dumps()
        gs = GraphSet.loads(st)
        self.assertEqual(gs, GraphSet(v))

        # skip this test, becasue string is treated as an element
#        gs = GraphSet(st)
#        self.assertEqual(gs, GraphSet(v))

        with tempfile.TemporaryFile() as f:
            gs.dump(f)
            f.seek(0)
            gs = GraphSet.load(f)
            self.assertEqual(gs, GraphSet(v))
Exemplo n.º 2
0
    def test_io(self):
        gs = GraphSet()
        st = gs.dumps()
        self.assertEqual(st, "B\n.\n")
        gs = GraphSet.loads(st)
        self.assertEqual(gs, GraphSet())

        gs = GraphSet([g0])
        st = gs.dumps()
        self.assertEqual(st, "T\n.\n")
        gs = GraphSet.loads(st)
        self.assertEqual(gs, GraphSet([g0]))

        v = [g0, g1, g12, g123, g1234, g134, g14, g4]
        gs = GraphSet(v)
        st = gs.dumps()
        gs = GraphSet.loads(st)
        self.assertEqual(gs, GraphSet(v))

        # skip this test, becasue string is treated as an element
        #        gs = GraphSet(st)
        #        self.assertEqual(gs, GraphSet(v))

        f = tempfile.TemporaryFile()
        gs.dump(f)
        f.seek(0)
        gs = GraphSet.load(f)
        self.assertEqual(gs, GraphSet(v))