Python: Add some tests for pathlib

This commit is contained in:
Rasmus Lerchedahl Petersen
2021-04-08 16:18:03 +02:00
parent 4be183c7f6
commit 8489403051
2 changed files with 17 additions and 2 deletions

View File

@@ -16,3 +16,18 @@ builtins.open(file="filepath") # $getAPathArgument="filepath"
io.open("filepath") # $getAPathArgument="filepath"
io.open(file="filepath") # $getAPathArgument="filepath"
from pathlib import Path, PosixPath, WindowsPath
p = Path("filepath")
posix = PosixPath("posix/filepath")
windows = WindowsPath("windows/filepath")
p.chmod(0o777) # MISSING: $getAPathArgument=p
posix.chmod(0o777) # MISSING: $getAPathArgument=posix
windows.chmod(0o777) # MISSING: $getAPathArgument=windows
with p.open() as f: # MISSING: $getAPathArgument=p
f.read()
p.write_bytes(b"hello") # MISSING: $getAPathArgument=p

View File

@@ -3,6 +3,6 @@ s = "taintedString"
if s.startswith("tainted"): # $checks=s branch=true
pass
sw = s.startswith # $ MISSING: checks=s branch=true
if sw("safe"):
sw = s.startswith
if sw("safe"): # $ MISSING: checks=s branch=true
pass