From 0465530d651aa326a89f17e32243bfdbd15c6cbe Mon Sep 17 00:00:00 2001 From: deeenes Date: Tue, 2 Jul 2024 00:17:13 +0200 Subject: [PATCH] `pytest`: marked slow tests, full suite: 51 tests in 59 sec, fast: 40 tests in 13.7 sec --- pyproject.toml | 4 ++++ tests/test_deseq2.py | 3 +++ tests/test_node.py | 4 ++++ tests/test_omics.py | 6 ++++++ 4 files changed, 17 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index f538415..8c74176 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -173,9 +173,13 @@ testpaths = [ "tests", ] xfail_strict = true +markers = [ + "slow: marks tests as slow (deselect with '-m \"not slow\"')" +] addopts = [ # "-Werror", # if 3rd party libs raise DeprecationWarnings, just use filterwarnings below "--import-mode=importlib", # allow using test files with same name + "-m not slow", ] filterwarnings = [ # "ignore:.*U.*mode is deprecated:DeprecationWarning", diff --git a/tests/test_deseq2.py b/tests/test_deseq2.py index fb7228f..ccc07ff 100644 --- a/tests/test_deseq2.py +++ b/tests/test_deseq2.py @@ -1,8 +1,11 @@ +import pytest + import pandas as pd from networkcommons._data.omics.deseq2 import deseq2 +@pytest.mark.slow def test_deseq2(): # Create dummy dataset for testing, samples as colnames, genes as rownames diff --git a/tests/test_node.py b/tests/test_node.py index 8a5dedc..c4d9ce6 100644 --- a/tests/test_node.py +++ b/tests/test_node.py @@ -53,6 +53,7 @@ def human_protein_ids() -> list[str]: return list(SAMPLE_HUMAN_PROTEINS.keys()) +@pytest.mark.slow def test_node_human_protein(human_protein_ids): for _id in human_protein_ids: @@ -62,6 +63,7 @@ def test_node_human_protein(human_protein_ids): assert node.asdict() == SAMPLE_HUMAN_PROTEINS[_id] +@pytest.mark.slow def test_node_id_translation(human_protein_ids): upc1_ensg = human_protein_ids[2] @@ -73,6 +75,7 @@ def test_node_id_translation(human_protein_ids): assert list(upc1.as_idtype('uniprot'))[0].asdict() == upc1_uniprot_attrs +@pytest.mark.slow def test_node_mouse_protein(): egfr_m = _node.Node('Egfr', organism = 'mouse') @@ -80,6 +83,7 @@ def test_node_mouse_protein(): assert egfr_m.asdict() == SAMPLE_MOUSE_PROTEINS['Egfr'] +@pytest.mark.slow def test_node_orthology_translation(): egfr_m_o_attrs = SAMPLE_MOUSE_PROTEINS['Egfr'].copy() diff --git a/tests/test_omics.py b/tests/test_omics.py index d19af3a..9c1dae2 100644 --- a/tests/test_omics.py +++ b/tests/test_omics.py @@ -28,6 +28,7 @@ def test_commons_url(): assert 'metadata' in url +@pytest.mark.slow def test_download(tmp_path): url = omics.common._commons_url('test', table = 'meta') @@ -43,6 +44,7 @@ def test_download(tmp_path): assert line.startswith('sample_ID\t') +@pytest.mark.slow def test_open(): url = omics.common._commons_url('test', table = 'meta') @@ -63,6 +65,7 @@ def test_open_df(): assert df.shape == (4, 2) +@pytest.mark.slow def test_decryptm_datasets(): dsets = omics.decryptm.decryptm_datasets() @@ -78,6 +81,7 @@ def decryptm_args(): return 'KDAC_Inhibitors', 'Acetylome', 'curves_CUDC101.txt' +@pytest.mark.slow def test_decryptm_table(decryptm_args): df = omics.decryptm.decryptm_table(*decryptm_args) @@ -87,6 +91,7 @@ def test_decryptm_table(decryptm_args): assert df.EC50.dtype == 'float64' +@pytest.mark.slow def test_decryptm_experiment(decryptm_args): dfs = omics.decryptm.decryptm_experiment(*decryptm_args[:2]) @@ -98,6 +103,7 @@ def test_decryptm_experiment(decryptm_args): assert dfs[3].EC50.dtype == 'float64' +@pytest.mark.slow def test_panacea(): dfs = omics.panacea()