Skip to content

Commit

Permalink
Merge pull request #12 from RMeli/tests
Browse files Browse the repository at this point in the history
Move tests outside of Python package
  • Loading branch information
RMeli authored Nov 17, 2021
2 parents 563fe78 + f481268 commit 0ba2909
Show file tree
Hide file tree
Showing 17 changed files with 31 additions and 74 deletions.
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

0 comments on commit 0ba2909

Please sign in to comment.