| 7 | |
| 8 | |
| 9 | def test_comment_picker_basic() -> None: |
| 10 | source = ( |
| 11 | 'a = 1 + 1 #: assignment\n' |
| 12 | 'b = 1 +\\\n 1 #: assignment including a CR\n' |
| 13 | 'c = (1 +\n 1) #: tuple \n' |
| 14 | 'd = {1, \n 1} #: set\n' |
| 15 | 'e = [1, \n 1] #: list #: additional comment\n' |
| 16 | 'f = "abc"\n' |
| 17 | '#: string; comment on next line (ignored)\n' |
| 18 | 'g = 1.0\n' |
| 19 | '"""float; string on next line"""\n' |
| 20 | ) |
| 21 | parser = Parser(source) |
| 22 | parser.parse() |
| 23 | assert parser.comments == { |
| 24 | ('', 'a'): 'assignment', |
| 25 | ('', 'b'): 'assignment including a CR', |
| 26 | ('', 'c'): 'tuple ', |
| 27 | ('', 'd'): ' set', |
| 28 | ('', 'e'): 'list #: additional comment', |
| 29 | ('', 'g'): 'float; string on next line', |
| 30 | } |
| 31 | |
| 32 | |
| 33 | def test_comment_picker_location() -> None: |