Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Imports isolation in tests #710

Open
juhoinkinen opened this issue Jun 2, 2023 · 1 comment
Open

Imports isolation in tests #710

juhoinkinen opened this issue Jun 2, 2023 · 1 comment

Comments

@juhoinkinen
Copy link
Member

When working on PR #708, I accidentally removed this inline import:

import annif.suggestion

This made annif index command fail:

...
File "/home/local/jmminkin/git/Annif/annif/cli.py", line 322, in run_index
    results = project.suggest_corpus(documents, backend_params).filter(limit, threshold)
  File "/home/local/jmminkin/git/Annif/annif/project.py", line 238, in suggest_corpus
    return annif.suggestion.SuggestionResults(suggestions)
AttributeError: module 'annif' has no attribute 'suggestion'

But this was not detected by tests for index command. Seems that some commands that are tested before import annif.suggestion, and this import remains for index command.

The tests should probably be some way more isolated to be able to detected this kind of possibility for bugs.

@osma
Copy link
Member

osma commented Jun 2, 2023

I think that could be a consequence of running the CLI tests via CliRunner. It simulates a CLI execution environment, but isn't quite the same as running the commands separately from a real CLI. If we wanted to test that, we'd need something like a shell script (or possibly even a bats test suite) that runs the annif commands separately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants