Exemplo n.º 1
0
 def test_multiple_elements(self):
     stream = load(StringIO('#{1 2 3} "foo"\n43,32'))
     self.assertEqual(set([1, 2, 3]), next(stream))
     self.assertEqual(u"foo", next(stream))
     self.assertEqual(43, next(stream))
     self.assertEqual(32, next(stream))
     self.assertRaises(StopIteration, next, stream)
Exemplo n.º 2
0
def time_edn():
    list(load(buf))
Exemplo n.º 3
0
 def test_custom_default(self):
     marker = object()
     handler = lambda a, b: (marker, b)
     stream = StringIO('#foo [1 2] #bar "qux"')
     parsed = list(load(stream, default=handler))
     self.assertEqual([(marker, (1, 2)), (marker, u"qux")], parsed)
Exemplo n.º 4
0
 def test_custom_tag(self):
     text = '#foo [1 2] #foo [3 4]'
     parsed = load(StringIO(text), {Symbol('foo'): reverse})
     self.assertEqual([[2, 1], [4, 3]], list(parsed))
Exemplo n.º 5
0
 def test_single_element(self):
     stream = load(StringIO('#{1 2 3}'))
     self.assertEqual(set([1, 2, 3]), next(stream))
     self.assertRaises(StopIteration, next, stream)
Exemplo n.º 6
0
def time_edn(f):
    start = datetime.now()
    list(load(f))
    end = datetime.now()
    return (end - start).total_seconds()