MCPcopy Index your code
hub / github.com/datacamp/pythonwhat / wrapper

Function wrapper

tests/helper.py:21–38  ·  view source on GitHub ↗
(*args, **kwargs)

Source from the content-addressed store, hash-verified

19def capture_test_data(f):
20 @wraps(f)
21 def wrapper(*args, **kwargs):
22 result = f(*args, **kwargs)
23
24 data = kwargs.copy()
25 del data["student_process"]
26 del data["solution_process"]
27 data["result"] = result
28
29 context = "other"
30 stack = inspect.stack()
31 for frame in stack:
32 _, filename = os.path.split(frame.filename)
33 if filename and filename.startswith("test_"):
34 context = filename
35 break
36 test_data[context].append(data.copy())
37
38 return result
39
40 return wrapper
41

Callers

nothing calls this directly

Calls 2

fFunction · 0.85
copyMethod · 0.80

Tested by

no test coverage detected