Back to index

python3.2  3.2.2
Public Member Functions
test.test_parser.IllegalSyntaxTestCase Class Reference

List of all members.

Public Member Functions

def check_bad_tree
def test_junk
def test_illegal_yield_1
def test_illegal_yield_2
def test_a_comma_comma_c
def test_illegal_operator
def test_malformed_global
def test_missing_import_source

Detailed Description

Definition at line 275 of file test_parser.py.


Member Function Documentation

def test.test_parser.IllegalSyntaxTestCase.check_bad_tree (   self,
  tree,
  label 
)

Definition at line 277 of file test_parser.py.

00277 
00278     def check_bad_tree(self, tree, label):
00279         try:
00280             parser.sequence2st(tree)
00281         except parser.ParserError:
00282             pass
00283         else:
00284             self.fail("did not detect invalid tree for %r" % label)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 408 of file test_parser.py.

00408 
00409     def test_a_comma_comma_c(self):
00410         # Illegal input: a,,c
00411         tree = \
00412         (258,
00413          (311,
00414           (290,
00415            (291,
00416             (292,
00417              (293,
00418               (295,
00419                (296,
00420                 (297,
00421                  (298, (299, (300, (301, (302, (303, (1, 'a')))))))))))))),
00422           (12, ','),
00423           (12, ','),
00424           (290,
00425            (291,
00426             (292,
00427              (293,
00428               (295,
00429                (296,
00430                 (297,
00431                  (298, (299, (300, (301, (302, (303, (1, 'c'))))))))))))))),
00432          (4, ''),
00433          (0, ''))
00434         self.check_bad_tree(tree, "a,,c")

Here is the call graph for this function:

Definition at line 435 of file test_parser.py.

00435 
00436     def test_illegal_operator(self):
00437         # Illegal input: a $= b
00438         tree = \
00439         (257,
00440          (264,
00441           (265,
00442            (266,
00443             (267,
00444              (312,
00445               (291,
00446                (292,
00447                 (293,
00448                  (294,
00449                   (296,
00450                    (297,
00451                     (298,
00452                      (299,
00453                       (300, (301, (302, (303, (304, (1, 'a'))))))))))))))),
00454              (268, (37, '$=')),
00455              (312,
00456               (291,
00457                (292,
00458                 (293,
00459                  (294,
00460                   (296,
00461                    (297,
00462                     (298,
00463                      (299,
00464                       (300, (301, (302, (303, (304, (1, 'b'))))))))))))))))),
00465            (4, ''))),
00466          (0, ''))
00467         self.check_bad_tree(tree, "a $= b")

Here is the call graph for this function:

Definition at line 289 of file test_parser.py.

00289 
00290     def test_illegal_yield_1(self):
00291         # Illegal yield statement: def f(): return 1; yield 1
00292         tree = \
00293         (257,
00294          (264,
00295           (285,
00296            (259,
00297             (1, 'def'),
00298             (1, 'f'),
00299             (260, (7, '('), (8, ')')),
00300             (11, ':'),
00301             (291,
00302              (4, ''),
00303              (5, ''),
00304              (264,
00305               (265,
00306                (266,
00307                 (272,
00308                  (275,
00309                   (1, 'return'),
00310                   (313,
00311                    (292,
00312                     (293,
00313                      (294,
00314                       (295,
00315                        (297,
00316                         (298,
00317                          (299,
00318                           (300,
00319                            (301,
00320                             (302, (303, (304, (305, (2, '1')))))))))))))))))),
00321                (264,
00322                 (265,
00323                  (266,
00324                   (272,
00325                    (276,
00326                     (1, 'yield'),
00327                     (313,
00328                      (292,
00329                       (293,
00330                        (294,
00331                         (295,
00332                          (297,
00333                           (298,
00334                            (299,
00335                             (300,
00336                              (301,
00337                               (302,
00338                                (303, (304, (305, (2, '1')))))))))))))))))),
00339                  (4, ''))),
00340                (6, ''))))),
00341            (4, ''),
00342            (0, ''))))
00343         self.check_bad_tree(tree, "def f():\n  return 1\n  yield 1")

Here is the call graph for this function:

Definition at line 344 of file test_parser.py.

00344 
00345     def test_illegal_yield_2(self):
00346         # Illegal return in generator: def f(): return 1; yield 1
00347         tree = \
00348         (257,
00349          (264,
00350           (265,
00351            (266,
00352             (278,
00353              (1, 'from'),
00354              (281, (1, '__future__')),
00355              (1, 'import'),
00356              (279, (1, 'generators')))),
00357            (4, ''))),
00358          (264,
00359           (285,
00360            (259,
00361             (1, 'def'),
00362             (1, 'f'),
00363             (260, (7, '('), (8, ')')),
00364             (11, ':'),
00365             (291,
00366              (4, ''),
00367              (5, ''),
00368              (264,
00369               (265,
00370                (266,
00371                 (272,
00372                  (275,
00373                   (1, 'return'),
00374                   (313,
00375                    (292,
00376                     (293,
00377                      (294,
00378                       (295,
00379                        (297,
00380                         (298,
00381                          (299,
00382                           (300,
00383                            (301,
00384                             (302, (303, (304, (305, (2, '1')))))))))))))))))),
00385                (264,
00386                 (265,
00387                  (266,
00388                   (272,
00389                    (276,
00390                     (1, 'yield'),
00391                     (313,
00392                      (292,
00393                       (293,
00394                        (294,
00395                         (295,
00396                          (297,
00397                           (298,
00398                            (299,
00399                             (300,
00400                              (301,
00401                               (302,
00402                                (303, (304, (305, (2, '1')))))))))))))))))),
00403                  (4, ''))),
00404                (6, ''))))),
00405            (4, ''),
00406            (0, ''))))
00407         self.check_bad_tree(tree, "def f():\n  return 1\n  yield 1")

Here is the call graph for this function:

Definition at line 285 of file test_parser.py.

00285 
00286     def test_junk(self):
00287         # not even remotely valid:
00288         self.check_bad_tree((1, 2, 3), "<junk>")

Here is the call graph for this function:

Definition at line 468 of file test_parser.py.

00468 
00469     def test_malformed_global(self):
00470         #doesn't have global keyword in ast
00471         tree = (257,
00472                 (264,
00473                  (265,
00474                   (266,
00475                    (282, (1, 'foo'))), (4, ''))),
00476                 (4, ''),
00477                 (0, ''))
00478         self.check_bad_tree(tree, "malformed global ast")

Here is the call graph for this function:

Definition at line 479 of file test_parser.py.

00479 
00480     def test_missing_import_source(self):
00481         # from import fred
00482         tree = \
00483             (257,
00484              (268,
00485               (269,
00486                (270,
00487                 (282,
00488                  (284, (1, 'from'), (1, 'import'),
00489                   (287, (285, (1, 'fred')))))),
00490                (4, ''))),
00491              (4, ''), (0, ''))
00492         self.check_bad_tree(tree, "from import fred")
00493 

Here is the call graph for this function:


The documentation for this class was generated from the following file: