File: test_fix_file.py

package info (click to toggle)
modernize 0.9-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 416 kB
  • sloc: python: 2,016; makefile: 145
file content (57 lines) | stat: -rw-r--r-- 718 bytes parent folder | download
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from __future__ import generator_stop

from utils import check_on_input

FILE_CALL = (
    """\
file('some/file/path', 'r')
""",
    """\
open('some/file/path', 'r')
""",
)

FILE_CONTEXT_MANAGER = (
    """\
with file('some/file/path', 'r') as file_:
    pass
""",
    """\
with open('some/file/path', 'r') as file_:
    pass
""",
)

FILE_ATTR = (
    """\
file('path').readlines
""",
    """\
open('path').readlines
""",
)

FILE_REF = (
    """\
file
""",
    """\
file
""",
)


def test_file_call():
    check_on_input(*FILE_CALL)


def test_file_context_manager():
    check_on_input(*FILE_CONTEXT_MANAGER)


def test_file_attr():
    check_on_input(*FILE_ATTR)


def test_file_ref():
    check_on_input(*FILE_REF)