Skip to content

Commit

Permalink
Added tests for write hook
Browse files Browse the repository at this point in the history
  • Loading branch information
AryazE committed Oct 27, 2023
1 parent 962f8a3 commit 3148d14
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/trace_single_hook/write/analysis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from typing import Optional
from dynapyt.analyses.BaseAnalysis import BaseAnalysis


class TestAnalysis(BaseAnalysis):
def begin_execution(self) -> None:
print("begin execution")

def end_execution(self) -> None:
print("end execution")

def write(self, dyn_ast, iid, old_values, new_value):
print(f"Writing {new_value} to {[ov.__code__.co_names for ov in old_values]}")
5 changes: 5 additions & 0 deletions tests/trace_single_hook/write/expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
begin execution
Writing 10 to [('a',)]
Writing test to [('b',)]
Writing testtesttesttesttesttesttesttesttesttest to [('c',)]
end execution
3 changes: 3 additions & 0 deletions tests/trace_single_hook/write/program.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
a = 10
b = "test"
c = a * b

0 comments on commit 3148d14

Please sign in to comment.