(self)
| 56 | self.assertFalse(_should_be_async("'\\ud800'\nawait foo")) |
| 57 | |
| 58 | def _get_top_level_cases(self): |
| 59 | # These are test cases that should be valid in a function |
| 60 | # but invalid outside of a function. |
| 61 | test_cases = [] |
| 62 | test_cases.append(("basic", "{val}")) |
| 63 | |
| 64 | # Note, in all conditional cases, I use True instead of |
| 65 | # False so that the peephole optimizer won't optimize away |
| 66 | # the return, so CPython will see this as a syntax error: |
| 67 | # |
| 68 | # while True: |
| 69 | # break |
| 70 | # return |
| 71 | # |
| 72 | # But not this: |
| 73 | # |
| 74 | # while False: |
| 75 | # return |
| 76 | # |
| 77 | # See https://bugs.python.org/issue1875 |
| 78 | |
| 79 | test_cases.append( |
| 80 | ( |
| 81 | "if", |
| 82 | dedent( |
| 83 | """ |
| 84 | if True: |
| 85 | {val} |
| 86 | """ |
| 87 | ), |
| 88 | ) |
| 89 | ) |
| 90 | |
| 91 | test_cases.append( |
| 92 | ( |
| 93 | "while", |
| 94 | dedent( |
| 95 | """ |
| 96 | while True: |
| 97 | {val} |
| 98 | break |
| 99 | """ |
| 100 | ), |
| 101 | ) |
| 102 | ) |
| 103 | |
| 104 | test_cases.append( |
| 105 | ( |
| 106 | "try", |
| 107 | dedent( |
| 108 | """ |
| 109 | try: |
| 110 | {val} |
| 111 | except: |
| 112 | pass |
| 113 | """ |
| 114 | ), |
| 115 | ) |
no test coverage detected