Skip to content

Commit

Permalink
Fix test suite (#796)
Browse files Browse the repository at this point in the history
* Skip tests requiring optional modules when they are absent.

The `gilda` and `semsimian` modules are optional dependencies, but the
tests that depend do not expect that they may not be present and error
out if they cannot be imported.

Since they are optional, their absence should not cause the test suite
to fail, so this commit ensures that the corresponding tests are
properly skipped if the optional modules are not found.

closes #794

* Prevent spurious warnings from causing test failure.

The `test_annotate_file` command may fail because the `annotate` command
may emit some unexpected warnings on STDERR about invalid CURIEs, even
if there are no errors and the expected output is normally produced on
STDOUT.

This commit amends the test so that it ignores any 'WARNING:' line in
the STDERR stream produced by the `annotate` command.

closes #795.
  • Loading branch information
gouttegd authored Aug 17, 2024
1 parent a0bf7ae commit ed29c27
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1522,7 +1522,7 @@ def test_annotate_file(self):
],
)
print("STDERR", result.stdout)
err = result.stderr
err = "\n".join([line for line in result.stderr.split("\n") if not line.startswith("WARNING")])
self.assertEqual("", err)
self.assertEqual(0, result.exit_code)
with open(outfile) as stream:
Expand Down
2 changes: 2 additions & 0 deletions tests/test_implementations/test_semsimian_implementation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import timeit
import unittest
from importlib.util import find_spec

from linkml_runtime.dumpers import yaml_dumper

Expand Down Expand Up @@ -31,6 +32,7 @@


@unittest.skipIf(os.name == "nt", "DB path loading inconsistent on Windows")
@unittest.skipIf(find_spec("semsimian") is None, "Semsimian not available")
class TestSemSimianImplementation(unittest.TestCase):
"""Implementation tests for Rust-based semantic similarity."""

Expand Down
10 changes: 8 additions & 2 deletions tests/test_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@
import unittest
from pathlib import Path

from gilda.grounder import Grounder
from gilda.term import Term
try:
from gilda.grounder import Grounder
from gilda.term import Term

have_gilda = True
except ImportError:
have_gilda = False

from oaklib.datamodels.text_annotator import TextAnnotationConfiguration
from oaklib.implementations.gilda import GildaImplementation
Expand All @@ -23,6 +28,7 @@
from tests import INPUT_DIR


@unittest.skipIf(not have_gilda, "Gilda not available")
class TestResource(unittest.TestCase):
def test_from_descriptor(self):
# no scheme
Expand Down

0 comments on commit ed29c27

Please sign in to comment.