def test_c(self): "correctly parse >> delimiter" x= [ { 'text' : 'a', 'quoter' : '>', 'raw' : '> a' }, [ { 'text' : 'b', 'quoter' : '>>', 'raw' : '>> b' } ], { 'text' : 'c', 'quoter' : '>', 'raw' : '> c' } ] x = self._massage(x) self.assertEqual( extract(c), x )
def test_d(self): "correctly parse cpan> delimiter with no text" x = [ [ { 'text' : '', 'empty' : 1, 'quoter' : '>', 'raw' : '>' } ], [ { 'text' : '', 'empty' : 1, 'quoter' : 'cpan>', 'raw' : 'cpan>' } ], [ { 'text' : '', 'empty' : 1, 'quoter' : '>', 'raw' : '>' } ] ] x = self._massage(x) self.assertEqual( extract(d), x )
def test_g(self): "correctly parse => delimiter" x = [ [ { 'text' : 'a', 'quoter' : '>', 'raw' : '> a' } ], [ { 'text' : 'b', 'quoter' : '=>', 'raw' : '=> b' } ], [ { 'text' : 'c', 'quoter' : '>', 'raw' : '> c' } ] ] x = self._massage(x) self.assertEqual( extract(g), x )
def test_e(self): "correctly handles a non-delimiter" x = [ [ { 'text' : 'a', 'quoter' : '>', 'raw' : '> a' } ], { 'text' : 'cpan > b', 'quoter' : '', 'raw' : 'cpan > b' }, [ { 'text' : 'c', 'quoter' : '>', 'raw' : '> c' } ], ] x = self._massage(x) self.assertEqual( extract(e), x )
def test_a(self): "Sample text is organized properly" x = [[{'text' : 'foo','quoter' : '>','raw' : '> foo', 'empty': False, 'separator': False}, [{'text' : 'Bar','quoter' : '> #','raw' : '> # Bar', 'empty':False, 'separator': False}], {'text' : 'baz','quoter' : '>','raw' : '> baz', 'empty':False, 'separator': False} ], {'text' : '','empty' : True,'quoter' : '','raw' : '', 'separator': False}, {'text' : 'quux','quoter' : '','raw' : 'quux', 'empty':False, 'separator': False} ] self.assertEqual( extract(a) , x )
def sample1_test(self): "Ensure separators work" x = [ {'text' : 'foo', 'quoter' : '', 'raw' : 'foo'}, {'text' : '============', 'quoter' : '', 'raw' : '============', 'separator' : 1 }, {'text' : 'bar', 'quoter' : '', 'raw' : 'bar'}, {'text' : '============', 'quoter' : '', 'raw' : '============', 'separator' : 1 }, {'text' : 'baz', 'quoter' : '', 'raw' : 'baz'}, ] x = self._massage(x) self.assertEquals( extract(sample1), x )
def test_f(self): "correctly parse => delimiter with blank lines" x = [ [ { 'text' : 'a', 'quoter' : '>', 'raw' : '> a' } ], { 'text' : '', 'empty' : 1, 'quoter' : '', 'raw' : '' }, [ { 'text' : 'b', 'quoter' : '=>', 'raw' : '=> b' } ], { 'text' : '', 'empty' : 1, 'quoter' : '', 'raw' : '' }, [ { 'text' : 'c', 'quoter' : '>', 'raw' : '> c' } ] ] x = self._massage(x) self.assertEqual( extract(f), x )
def sample2_test(self): "Separators should work in quoted areas" x = [ {'text' : 'foo', 'quoter' : '', 'raw' : 'foo'}, [ {'text' : 'bar', 'quoter' : '>', 'raw' : '> bar'}, {'text' : '============', 'quoter' : '>', 'raw' : '> ============', 'separator' : 1 }, {'text' : 'baz', 'quoter' : '>', 'raw' : '> baz'}, {'text' : '============', 'quoter' : '>', 'raw' : '> ============', 'separator' : 1 }, ], ] x = self._massage(x) self.assertEquals( extract(sample2), x )
def test_b(self): "Skipping levels works okay" x = [ { 'text' : '', 'empty' : '1', 'quoter' : '', 'raw' : '' }, [ { 'text' : 'foo', 'quoter' : '>', 'raw' : '> foo' }, [ [ { 'text' : 'baz', 'quoter' : '> > >', 'raw' : '> > > baz' } ], { 'text' : 'quux', 'quoter' : '> >', 'raw' : '> > quux' } ], { 'text' : 'quuux', 'quoter' : '>', 'raw' : '> quuux' } ], { 'text' : 'quuuux', 'quoter' : '', 'raw' : 'quuuux' } ]; x = self._massage(x) self.assertEqual( extract(b), x )
def test_ntk(self): "Wow... don't segfault" extract(ntk)
def test_b(self): "Real world test b" x = self._massage(expected_b) self.assertEqual( extract(b), x )
def test(self): "Real world test" x = self._massage(expected) self.assertEqual( extract(a), x )
def test(self): "Check empty" a = "" x = {'text' : "", 'quoter': "", 'raw': "", "empty":True} x = self._massage(x) self.assertEquals( extract(a), x )
def none_test(self): "Check None" a = None x = {'text' : "", 'quoter': "", 'raw': "", "empty":True} x = self._massage(x) self.assertEquals( extract(a), x )