コード例 #1
0
 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 )
コード例 #2
0
 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 )
コード例 #3
0
 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 )
コード例 #4
0
 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 )
コード例 #5
0
 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 )
コード例 #6
0
 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 )
コード例 #7
0
 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 )
コード例 #8
0
 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 )
コード例 #9
0
 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 )
コード例 #10
0
 def test_ntk(self):
     "Wow... don't segfault"
     extract(ntk)
コード例 #11
0
 def test_b(self):
     "Real world test b"
     x = self._massage(expected_b)
     self.assertEqual( extract(b), x )
コード例 #12
0
 def test(self):
     "Real world test"
     x = self._massage(expected)
     self.assertEqual( extract(a), x )
コード例 #13
0
 def test(self):
     "Check empty"
     a = ""
     x = {'text' : "", 'quoter': "", 'raw': "", "empty":True}
     x = self._massage(x)
     self.assertEquals( extract(a), x )
コード例 #14
0
 def none_test(self):
     "Check None"
     a = None
     x = {'text' : "", 'quoter': "", 'raw': "", "empty":True}
     x = self._massage(x)
     self.assertEquals( extract(a), x )