pedal-edu / pedal

A collection of tools to analyze student's Python source code
https://pedal-edu.github.io/pedal/
MIT License
29 stars 7 forks source link

Runtime assertion for checking get_call_arguments #85

Open acbart opened 3 years ago

acbart commented 3 years ago
new_record_calls = get_call_arguments('new_record')
for call in new_record_calls:
    if not isinstance(call.get('__ARG0'), str):
        gently("The first argument passed to `new_record` should be a string!")

This seems to me like it should be a new assertion, of some kind, though I'm not entirely clear what it would look like. Something like assert_function_called_with_type and then you pass in the values for isinstance?

lukesg08 commented 3 years ago

In this case, I think that the order of the arguments should also matter (unless it's a named argument), so we'd need to pass in something to specify which argument you are talking about. But that seems like a solid addition to the assertions library.