-
Notifications
You must be signed in to change notification settings - Fork 73
Description
Describe the bug
As the title says, if you have a notebook with tests in the metadata they can not be executed if a directory named "tests" exists in the same location as the notebook.
To Reproduce
Steps to reproduce the behavior:
- Create and assignment with a test stored in notebook metadata (the default settings).
- Place directory named "tests" in the same directory as the notebook.
- Attempt to check an exercise with
grader.check(...). - Testing failes with a
FileNotFoundErrorbecause the test can not be found.
Expected behavior
The check should run as usual, reading the test data from the notebook metadata.
Versions
Python: 3.12.8
Otter: 6.1.3
Additional context
The reason for this behavior is that resolve_test_info() check first if there are tests stored in a "tests" directory and only resorts to metadata tests if this directory does not exists. See here. Since the source of the tests to be checked is mistakenly resolved to a non-existant file in the unrelated "tests" directory, the check fails with a FileNotFoundError.
I am not familiar with the codebase, but maybe the resolution priority could be different or more thourough so that it does not assume that the tests is in the "tests" directory just because it exists" or by reversing the priority, first checking if the concrete test exists in the notebook metadata.
The Notebook class constructor has a test_dir option and if this is set to a non-existant directory everything works as expected again. So a rather simple fix could be to expose the test_dir location as a configuration option and then add the respective argument to the initialization cell.
I am willing to work on this myself, if someone tells me which of the approaches I should take.