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 outside of Python package #12

Merged
merged 2 commits into from
Nov 17, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
shell: bash -l {0}

run: |
pytest -v --cov=gnina --cov-report=xml --color=yes gnina/tests/ --nogpu
pytest -v --cov=gnina --cov-report=xml --color=yes tests/ --nogpu

- name: CodeCov
uses: codecov/codecov-action@v1
Expand Down
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[pytest]
minversion = 6.0
testpaths =
gnina/tests/
tests/
File renamed without changes.
29 changes: 29 additions & 0 deletions gnina/tests/conftest.py → tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os

import molgrid
import pytest
import torch
Expand Down Expand Up @@ -35,3 +37,30 @@ def device(pytestconfig):
device = torch.device("cpu")

return device


@pytest.fixture(scope="session")
def trainfile() -> str:
"""
Path to small training file.
"""
path = os.path.dirname(__file__)
return os.path.join(path, "data", "test.types")


@pytest.fixture
def testfile() -> str:
"""
Path to small test file.
"""
path = os.path.dirname(__file__)
return os.path.join(path, "data", "test.types")


@pytest.fixture(scope="session")
def dataroot() -> str:
"""
Path to test directory.
"""
path = os.path.dirname(__file__)
return os.path.join(path, "data", "mols")
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
21 changes: 0 additions & 21 deletions gnina/tests/test_dataloaders.py → tests/test_dataloaders.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,10 @@
import os
import sys

import pytest
import torch

from gnina import setup, training
from gnina.dataloaders import GriddedExamplesLoader


@pytest.fixture
def trainfile() -> str:
"""
Path to small training file.
"""
gnina_path = os.path.dirname(sys.modules["gnina"].__file__)
return os.path.join(gnina_path, "data", "test.types")


@pytest.fixture
def dataroot() -> str:
"""
Path to test directory.
"""
gnina_path = os.path.dirname(sys.modules["gnina"].__file__)
return os.path.join(gnina_path, "data", "test")


@pytest.mark.parametrize("iteration_scheme", ["small", "large"])
def test_GriddedExamplesLoader(trainfile, dataroot, device, iteration_scheme):
# Do not shuffle examples randomly when loading the batch
Expand Down
File renamed without changes.
21 changes: 0 additions & 21 deletions gnina/tests/test_inference.py → tests/test_inference.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,8 @@
import os
import sys

import pytest

from gnina import inference, training


@pytest.fixture
def trainfile() -> str:
gnina_path = os.path.dirname(sys.modules["gnina"].__file__)
return os.path.join(gnina_path, "data", "test.types")


@pytest.fixture
def testfile() -> str:
gnina_path = os.path.dirname(sys.modules["gnina"].__file__)
return os.path.join(gnina_path, "data", "test.types")


@pytest.fixture
def dataroot() -> str:
gnina_path = os.path.dirname(sys.modules["gnina"].__file__)
return os.path.join(gnina_path, "data", "test")


def test_inference(trainfile, testfile, dataroot, tmpdir, device):
epochs = 1

Expand Down
File renamed without changes.
File renamed without changes.
15 changes: 0 additions & 15 deletions gnina/tests/test_setup.py → tests/test_setup.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,9 @@
import os
import sys

import pytest
import torch

from gnina import setup, training


@pytest.fixture
def trainfile() -> str:
gnina_path = os.path.dirname(sys.modules["gnina"].__file__)
return os.path.join(gnina_path, "data", "test.types")


@pytest.fixture
def dataroot() -> str:
gnina_path = os.path.dirname(sys.modules["gnina"].__file__)
return os.path.join(gnina_path, "data", "test")


def test_setup_example_provider_default(trainfile, dataroot, device):
# Do not shuffle examples randomly when loading the batch
# This ensures reproducibility
Expand Down
15 changes: 0 additions & 15 deletions gnina/tests/test_training.py → tests/test_training.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,8 @@
import os
import sys

import pytest

from gnina import training


@pytest.fixture
def trainfile() -> str:
gnina_path = os.path.dirname(sys.modules["gnina"].__file__)
return os.path.join(gnina_path, "data", "test.types")


@pytest.fixture
def dataroot() -> str:
gnina_path = os.path.dirname(sys.modules["gnina"].__file__)
return os.path.join(gnina_path, "data", "test")


def test_options_default(trainfile):
args = training.options([trainfile])

Expand Down