@@ -33,37 +33,78 @@ def test_os_open_ok(self, arg):
3333 int(0) #@
3434 foo() #@
3535 os.open("file.txt") #@
36+ os.open("file.txt", flags, mode) #@
3637 os.open("file.txt", os.O_RDONLY) #@
38+ os.open("file.txt", os.O_RDONLY, mode) #@
3739 os.open("file.txt", os.O_RDONLY, 0o644) #@
3840 os.open("file.txt", os.O_RDONLY | os.O_NOFOLLOW) #@
41+ os.open("file.txt", os.O_RDONLY | os.O_NOFOLLOW, mode) #@
3942 os.open("file.txt", os.O_RDONLY | os.O_NOFOLLOW, 0o644) #@
43+ os.open("file.txt", os.O_RDONLY, mode=mode) #@
44+ os.open("file.txt", os.O_RDONLY, mode=0o644) #@
45+ os.open("file.txt", os.O_RDONLY | os.O_NOFOLLOW, mode=mode) #@
46+ os.open("file.txt", os.O_RDONLY | os.O_NOFOLLOW, mode=0o644) #@
4047 bla.open("file.txt") #@
4148 bla.open("file.txt", os.O_RDONLY) #@
49+ bla.open("file.txt", flags=os.O_RDONLY) #@
50+ bla.open("file.txt", os.O_RDONLY, mode) #@
4251 bla.open("file.txt", os.O_RDONLY, 0o644) #@
43- bla.open("file.txt", os.O_RDONLY, 0o755 ) #@
52+ bla.open("file.txt", os.O_RDONLY, 0o777 ) #@
4453 bla.open("file.txt", os.O_RDONLY | os.O_NOFOLLOW) #@
54+ bla.open("file.txt", os.O_RDONLY | os.O_NOFOLLOW, mode) #@
4555 bla.open("file.txt", os.O_RDONLY | os.O_NOFOLLOW, 0o644) #@
46- bla.open("file.txt", os.O_RDONLY | os.O_NOFOLLOW, 0o755) #@
56+ bla.open("file.txt", os.O_RDONLY | os.O_NOFOLLOW, 0o777) #@
57+ bla.open("file.txt", os.O_RDONLY, mode=mode) #@
58+ bla.open("file.txt", os.O_RDONLY, mode=0o644) #@
59+ bla.open("file.txt", os.O_RDONLY, mode=0o777) #@
60+ bla.open("file.txt", os.O_RDONLY | os.O_NOFOLLOW) #@
61+ bla.open("file.txt", os.O_RDONLY | os.O_NOFOLLOW, mode=mode) #@
62+ bla.open("file.txt", os.O_RDONLY | os.O_NOFOLLOW, mode=0o644) #@
63+ bla.open("file.txt", os.O_RDONLY | os.O_NOFOLLOW, mode=0o777) #@
4764 with os.open("file.txt") as fd: fd.read() #@
65+ with os.open("file.txt", flags, mode) as fd: fd.read() #@
4866 with os.open("file.txt", os.O_RDONLY) as fd: fd.read() #@
67+ with os.open("file.txt", os.O_RDONLY, mode) as fd: fd.read() #@
4968 with os.open("file.txt", os.O_RDONLY, 0o644) as fd: fd.read() #@
5069 with os.open("file.txt", os.O_RDONLY | os.O_NOFOLLOW) as fd: fd.read() #@
70+ with os.open("file.txt", os.O_RDONLY | os.O_NOFOLLOW, mode) as fd: fd.read() #@
5171 with os.open("file.txt", os.O_RDONLY | os.O_NOFOLLOW, 0o644) as fd: fd.read() #@
72+ with os.open("file.txt", flags=flags, mode=mode) as fd: fd.read() #@
73+ with os.open("file.txt", flags=os.O_RDONLY, mode=mode) as fd: fd.read() #@
74+ with os.open("file.txt", flags=os.O_RDONLY, mode=0o644) as fd: fd.read() #@
75+ with os.open("file.txt", flags=os.O_RDONLY | os.O_NOFOLLOW, mode=mode) as fd: fd.read() #@
76+ with os.open("file.txt", flags=os.O_RDONLY | os.O_NOFOLLOW, mode=0o644) as fd: fd.read() #@
5277 with bla.open("file.txt") as fd: fd.read() #@
5378 with bla.open("file.txt", os.O_RDONLY) as fd: fd.read() #@
79+ with bla.open("file.txt", os.O_RDONLY, mode) as fd: fd.read() #@
5480 with bla.open("file.txt", os.O_RDONLY, 0o644) as fd: fd.read() #@
55- with bla.open("file.txt", os.O_RDONLY, 0o755 ) as fd: fd.read() #@
81+ with bla.open("file.txt", os.O_RDONLY, 0o777 ) as fd: fd.read() #@
5682 with bla.open("file.txt", os.O_RDONLY | os.O_NOFOLLOW) as fd: fd.read() #@
83+ with bla.open("file.txt", os.O_RDONLY | os.O_NOFOLLOW, mode) as fd: fd.read() #@
5784 with bla.open("file.txt", os.O_RDONLY | os.O_NOFOLLOW, 0o644) as fd: fd.read() #@
58- with bla.open("file.txt", os.O_RDONLY | os.O_NOFOLLOW, 0o755) as fd: fd.read() #@
85+ with bla.open("file.txt", os.O_RDONLY | os.O_NOFOLLOW, 0o777) as fd: fd.read() #@
86+ with bla.open("file.txt", flags=os.O_RDONLY) as fd: fd.read() #@
87+ with bla.open("file.txt", flags=os.O_RDONLY, mode=mode) as fd: fd.read() #@
88+ with bla.open("file.txt", flags=os.O_RDONLY, mode=0o644) as fd: fd.read() #@
89+ with bla.open("file.txt", flags=os.O_RDONLY, mode=0o777) as fd: fd.read() #@
90+ with bla.open("file.txt", flags=os.O_RDONLY | os.O_NOFOLLOW, mode=mode) as fd: fd.read() #@
91+ with bla.open("file.txt", flags=os.O_RDONLY | os.O_NOFOLLOW, mode=0o644) as fd: fd.read() #@
92+ with bla.open("file.txt", flags=os.O_RDONLY | os.O_NOFOLLOW, mode=0o777) as fd: fd.read() #@
5993 """
6094 )
6195
6296 self .checker .set_os_open_mode ('True' )
6397 assert self .checker ._prefer_os_open
6498
65- call_nodes = nodes [:14 ]
66- with_nodes = nodes [14 :]
99+ call_nodes = []
100+ with_nodes = []
101+
102+ # Find index of first line starting with 'with'
103+ for node in nodes :
104+ if isinstance (node , astroid .With ):
105+ with_nodes .append (node )
106+ else :
107+ call_nodes .append (node )
67108
68109 with self .assertNoMessages ():
69110 for idx , node in enumerate (call_nodes ):
0 commit comments