dsa-ou / algoesup

Algorithmic essays support: examples, templates, guides, library
https://dsa-ou.github.io/algoesup/
BSD 3-Clause "New" or "Revised" License
2 stars 0 forks source link

`test` crashes on built-in functions #45

Closed mwermelinger closed 1 month ago

mwermelinger commented 1 month ago

The test function uses f.__code__.co_argcount to find out how many arguments f has, but built-in functions don't have the __code__ attribute and thus something like test(sorted, [...]) crashes. This is a minor limitation as we usually don't test built-in functions. The solution is to

or

densnow commented 1 month ago

It looks like the inspect module could be a more robust way to do this, and more specifically inspect.signature. I'll just leave the link to the documentation here for now.

mwermelinger commented 1 month ago

Thanks, but the inspect documentation says that some CPython built-ins can't be handled either, so I'll just change the test docstring.