aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/parso/py2/tests/test_pep8.py
blob: fe65278de28f3d46526f2e362b0e11feddc1c3c1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import parso 
 
 
def issues(code): 
    grammar = parso.load_grammar() 
    module = parso.parse(code) 
    return grammar._get_normalizer_issues(module) 
 
 
def test_eof_newline(): 
    def assert_issue(code): 
        found = issues(code) 
        assert len(found) == 1 
        issue, = found 
        assert issue.code == 292 
 
    assert not issues('asdf = 1\n') 
    assert_issue('asdf = 1') 
    assert_issue('asdf = 1\n# foo') 
    assert_issue('# foobar') 
    assert_issue('') 
    assert_issue('foo = 1  # comment') 
 
 
def test_eof_blankline(): 
    def assert_issue(code): 
        found = issues(code) 
        assert len(found) == 1 
        issue, = found 
        assert issue.code == 391 
 
    assert_issue('asdf = 1\n\n') 
    assert_issue('# foobar\n\n') 
    assert_issue('\n\n') 
 
def test_shebang(): 
    assert not issues('#!\n') 
    assert not issues('#!/foo\n') 
    assert not issues('#! python\n')