Python parser.sequence2st() Examples

The following are 21 code examples of parser.sequence2st(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module parser , or try the search function .
Example #1
Source File: test_parser.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 6 votes vote down vote up
def test_illegal_encoding(self):
        # Illegal encoding declaration
        tree = \
            (338,
             (257, (0, '')))
        self.check_bad_tree(tree, "missed encoding")
        tree = \
            (338,
             (257, (0, '')),
              b'iso-8859-1')
        self.check_bad_tree(tree, "non-string encoding")
        tree = \
            (338,
             (257, (0, '')),
              '\udcff')
        with self.assertRaises(UnicodeEncodeError):
            parser.sequence2st(tree) 
Example #2
Source File: test_parser.py    From gcblue with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def roundtrip(self, f, s):
        st1 = f(s)
        t = st1.totuple()
        try:
            st2 = parser.sequence2st(t)
        except parser.ParserError, why:
            self.fail("could not roundtrip %r: %s" % (s, why)) 
Example #3
Source File: test_parser.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def check_bad_tree(self, tree, label):
        try:
            parser.sequence2st(tree)
        except parser.ParserError:
            pass
        else:
            self.fail("did not detect invalid tree for %r" % label) 
Example #4
Source File: test_parser.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def roundtrip(self, f, s):
        st1 = f(s)
        t = st1.totuple()
        try:
            st2 = parser.sequence2st(t)
        except parser.ParserError, why:
            self.fail("could not roundtrip %r: %s" % (s, why)) 
Example #5
Source File: test_parser.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def check_bad_tree(self, tree, label):
        try:
            parser.sequence2st(tree)
        except parser.ParserError:
            pass
        else:
            self.fail("did not detect invalid tree for %r" % label) 
Example #6
Source File: test_parser.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def roundtrip(self, f, s):
        st1 = f(s)
        t = st1.totuple()
        try:
            st2 = parser.sequence2st(t)
        except parser.ParserError, why:
            self.fail("could not roundtrip %r: %s" % (s, why)) 
Example #7
Source File: test_parser.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
def check_bad_tree(self, tree, label):
        try:
            parser.sequence2st(tree)
        except parser.ParserError:
            pass
        else:
            self.fail("did not detect invalid tree for %r" % label) 
Example #8
Source File: test_parser.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
def roundtrip(self, f, s):
        st1 = f(s)
        t = st1.totuple()
        try:
            st2 = parser.sequence2st(t)
        except parser.ParserError, why:
            self.fail("could not roundtrip %r: %s" % (s, why)) 
Example #9
Source File: test_parser.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
def check_bad_tree(self, tree, label):
        try:
            parser.sequence2st(tree)
        except parser.ParserError:
            pass
        else:
            self.fail("did not detect invalid tree for %r" % label) 
Example #10
Source File: test_parser.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
def roundtrip(self, f, s):
        st1 = f(s)
        t = st1.totuple()
        try:
            st2 = parser.sequence2st(t)
        except parser.ParserError as why:
            self.fail("could not roundtrip %r: %s" % (s, why))

        self.assertEqual(t, st2.totuple(),
                         "could not re-generate syntax tree") 
Example #11
Source File: test_parser.py    From gcblue with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def check_bad_tree(self, tree, label):
        try:
            parser.sequence2st(tree)
        except parser.ParserError:
            pass
        else:
            self.fail("did not detect invalid tree for %r" % label) 
Example #12
Source File: test_parser.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def roundtrip(self, f, s):
        st1 = f(s)
        t = st1.totuple()
        try:
            st2 = parser.sequence2st(t)
        except parser.ParserError, why:
            self.fail("could not roundtrip %r: %s" % (s, why)) 
Example #13
Source File: test_parser.py    From ironpython3 with Apache License 2.0 5 votes vote down vote up
def check_bad_tree(self, tree, label):
        try:
            parser.sequence2st(tree)
        except parser.ParserError:
            pass
        else:
            self.fail("did not detect invalid tree for %r" % label) 
Example #14
Source File: test_parser.py    From ironpython3 with Apache License 2.0 5 votes vote down vote up
def roundtrip(self, f, s):
        st1 = f(s)
        t = st1.totuple()
        try:
            st2 = parser.sequence2st(t)
        except parser.ParserError as why:
            self.fail("could not roundtrip %r: %s" % (s, why))

        self.assertEqual(t, st2.totuple(),
                         "could not re-generate syntax tree") 
Example #15
Source File: test_parser.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def check_bad_tree(self, tree, label):
        try:
            parser.sequence2st(tree)
        except parser.ParserError:
            pass
        else:
            self.fail("did not detect invalid tree for %r" % label) 
Example #16
Source File: test_parser.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def roundtrip(self, f, s):
        st1 = f(s)
        t = st1.totuple()
        try:
            st2 = parser.sequence2st(t)
        except parser.ParserError as why:
            self.fail("could not roundtrip %r: %s" % (s, why))

        self.assertEqual(t, st2.totuple(),
                         "could not re-generate syntax tree") 
Example #17
Source File: test_parser.py    From oss-ftp with MIT License 5 votes vote down vote up
def check_bad_tree(self, tree, label):
        try:
            parser.sequence2st(tree)
        except parser.ParserError:
            pass
        else:
            self.fail("did not detect invalid tree for %r" % label) 
Example #18
Source File: test_parser.py    From oss-ftp with MIT License 5 votes vote down vote up
def roundtrip(self, f, s):
        st1 = f(s)
        t = st1.totuple()
        try:
            st2 = parser.sequence2st(t)
        except parser.ParserError, why:
            self.fail("could not roundtrip %r: %s" % (s, why)) 
Example #19
Source File: test_parser.py    From BinderFilter with MIT License 5 votes vote down vote up
def check_bad_tree(self, tree, label):
        try:
            parser.sequence2st(tree)
        except parser.ParserError:
            pass
        else:
            self.fail("did not detect invalid tree for %r" % label) 
Example #20
Source File: test_parser.py    From BinderFilter with MIT License 5 votes vote down vote up
def roundtrip(self, f, s):
        st1 = f(s)
        t = st1.totuple()
        try:
            st2 = parser.sequence2st(t)
        except parser.ParserError, why:
            self.fail("could not roundtrip %r: %s" % (s, why)) 
Example #21
Source File: test_parser.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def check_bad_tree(self, tree, label):
        try:
            parser.sequence2st(tree)
        except parser.ParserError:
            pass
        else:
            self.fail("did not detect invalid tree for %r" % label)