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

Move tests out of package #1459

Merged
merged 11 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions .azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ trigger:

variables:
RUN_COVERAGE: no
# TODO: remove paths after moving tests to test dir: https://github.com/scverse/anndata/issues/1451
PYTEST_ADDOPTS: --color=yes --junitxml=test-data/test-results.xml anndata ./src/anndata/tests ./docs/concatenation.rst
PYTEST_ADDOPTS: --color=yes --junitxml=test-data/test-results.xml
DEPENDENCIES_VERSION: "latest" # |"pre-release" | "minimum-version"
TEST_TYPE: "standard" # | "coverage"

Expand Down Expand Up @@ -85,16 +84,6 @@ jobs:
displayName: "PyTest (treat warnings as errors)"
condition: eq(variables['TEST_TYPE'], 'strict-warning')

# TODO: remove: https://github.com/scverse/anndata/issues/1451
- task: PythonScript@0
inputs:
scriptSource: inline
script: |
import sys, xml.etree.ElementTree as ET
results = ET.parse("./test-data/test-results.xml").findall("./*/*")
sys.exit(0 if len(results) > 3000 else f"Error: only {len(results)} tests run")
displayName: "Check if enough tests ran"

- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: Cobertura
Expand Down
19 changes: 6 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,6 @@ test = [
]
gpu = ["cupy"]

[tool.hatch.build]
exclude = [
"src/anndata/tests/conftest.py",
"src/anndata/tests/test_*.py",
"src/anndata/tests/data",
]
[tool.hatch.version]
source = "vcs"
[tool.hatch.build.hooks.vcs]
Expand All @@ -125,16 +119,14 @@ exclude_also = [

[tool.pytest.ini_options]
addopts = [
# "--import-mode=importlib", # TODO: enable: https://github.com/scverse/anndata/issues/1451
"--import-mode=importlib",
flying-sheep marked this conversation as resolved.
Show resolved Hide resolved
"--strict-markers",
"--doctest-modules",
"--pyargs",
]
filterwarnings = [
'ignore:Support for Awkward Arrays is currently experimental',
'ignore:Outer joins on awkward\.Arrays',
# TODO: replace both lines above with this one once we figured out how prevent ImportPathMismatchError
# 'ignore::anndata._warnings.ExperimentalFeatureWarning',
'ignore::anndata._warnings.ExperimentalFeatureWarning',
'ignore::anndata.OldFormatWarning',
flying-sheep marked this conversation as resolved.
Show resolved Hide resolved
]
# When `--strict-warnings` is used, all warnings are treated as errors, except those:
filterwarnings_when_strict = [
Expand All @@ -146,7 +138,8 @@ filterwarnings_when_strict = [
]
python_files = "test_*.py"
testpaths = [
"anndata", # docstrings and unit tests (module name due to --pyargs)
"anndata", # docstrings (module name due to --pyargs)
"./tests", # unit tests
"./docs/concatenation.rst", # further doctests
]
# For some reason this effects how logging is shown when tests are run
Expand Down Expand Up @@ -180,7 +173,7 @@ ignore = [
]
[tool.ruff.lint.per-file-ignores]
# E721 comparing types, but we specifically are checking that we aren't getting subtypes (views)
"src/anndata/tests/test_readwrite.py" = ["E721"]
"tests/test_readwrite.py" = ["E721"]
[tool.ruff.lint.isort]
known-first-party = ["anndata"]
required-imports = ["from __future__ import annotations"]
Expand Down
19 changes: 0 additions & 19 deletions src/anndata/tests/conftest.py

This file was deleted.

10 changes: 10 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from __future__ import annotations

import pytest

from anndata.tests.helpers import subset_func # noqa: F401


@pytest.fixture
def backing_h5ad(tmp_path):
return tmp_path / "test.h5ad"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -467,21 +467,21 @@ def test_readloom_deprecations(tmp_path):


def test_read_csv():
adata = ad.read_csv(HERE / "adata.csv")
adata = ad.read_csv(HERE / "data" / "adata.csv")
assert adata.obs_names.tolist() == ["r1", "r2", "r3"]
assert adata.var_names.tolist() == ["c1", "c2"]
assert adata.X.tolist() == X_list


def test_read_tsv_strpath():
adata = ad.read_text(str(HERE / "adata-comments.tsv"), "\t")
adata = ad.read_text(str(HERE / "data" / "adata-comments.tsv"), "\t")
assert adata.obs_names.tolist() == ["r1", "r2", "r3"]
assert adata.var_names.tolist() == ["c1", "c2"]
assert adata.X.tolist() == X_list


def test_read_tsv_iter():
with (HERE / "adata-comments.tsv").open() as f:
with (HERE / "data" / "adata-comments.tsv").open() as f:
adata = ad.read_text(f, "\t")
assert adata.obs_names.tolist() == ["r1", "r2", "r3"]
assert adata.var_names.tolist() == ["c1", "c2"]
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading