mirror of
https://github.com/github/codeql.git
synced 2026-01-06 19:20:25 +01:00
We got into problems since using `string.py` would shadow the string module from the standard library. By some reason I adopted a pattern of `_` as suffix, but let us just use the standard pattern of `test_` prefix like a normal testing framework like pytest does.
33 lines
693 B
Python
33 lines
693 B
Python
# Add taintlib to PATH so it can be imported during runtime without any hassle
|
|
import sys; import os; sys.path.append(os.path.dirname(os.path.dirname((__file__))))
|
|
from taintlib import *
|
|
|
|
# This has no runtime impact, but allows autocomplete to work
|
|
from typing import TYPE_CHECKING
|
|
if TYPE_CHECKING:
|
|
from ..taintlib import *
|
|
|
|
# Actual tests
|
|
|
|
def test_access():
|
|
tainted_list = TAINTED_LIST
|
|
|
|
ensure_tainted(
|
|
tainted_list.copy(),
|
|
)
|
|
|
|
|
|
def list_clear():
|
|
tainted_string = TAINTED_STRING
|
|
tainted_list = [tainted_string]
|
|
|
|
ensure_tainted(tainted_list)
|
|
|
|
tainted_list.clear()
|
|
ensure_not_tainted(tainted_list)
|
|
|
|
# Make tests runable
|
|
|
|
test_access()
|
|
list_clear()
|