Skip to content

Commit

Permalink
test importable
Browse files Browse the repository at this point in the history
  • Loading branch information
maxme1 committed Oct 3, 2024
1 parent a9b4861 commit 5547483
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ jobs:
- name: Test with pytest
if: "! github.event.pull_request.head.repo.fork "
run: |
pytest tests -m "not raw" --junitxml=reports/junit-${{ matrix.python-version }}.xml --cov="$MODULE_PARENT/$MODULE_NAME" --cov-report=xml --cov-branch
# pytest tests -m "not raw" --junitxml=reports/junit-${{ matrix.python-version }}.xml --cov="$MODULE_PARENT/$MODULE_NAME" --cov-report=xml --cov-branch
# for now we only test that everything is importable
python -c "from $MODULE_NAME import *"
- name: Generate coverage report
if: "! github.event.pull_request.head.repo.fork "
run: |
Expand Down
29 changes: 14 additions & 15 deletions tests/test_consistency.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,15 @@
MAPPING = gather_datasets()
DATASETS = [x[0] for x in MAPPING.values()]
NAMES = list(MAPPING)
ROOT_MAPPING = {
AMOS: '/shared/data/amos22',
}


@pytest.mark.raw
@pytest.mark.parametrize('cls', DATASETS, ids=NAMES)
def test_ids_availability(cls):
assert len(cls().ids) > 0


@pytest.mark.raw
@pytest.mark.parametrize('cls', DATASETS, ids=NAMES)
def test_pickleable(cls):
raw = cls()[0]
Expand All @@ -36,18 +35,18 @@ def test_pickleable(cls):
assert f() == g()


@pytest.mark.raw
@pytest.mark.parametrize('cls', ROOT_MAPPING, ids=[cls.__name__ for cls in ROOT_MAPPING])
def test_cache_consistency(cls):
raw = cls(root=ROOT_MAPPING[cls])
cached = raw.cached()
fields = {x.name for x in raw._container.outputs} - {'ids', 'id', 'cached'}

ids = raw.ids
assert ids == cached.ids
for i in ids:
for field in fields:
compare(getattr(raw, field)(i), getattr(cached, field)(i))
# @pytest.mark.raw
# @pytest.mark.parametrize('cls', ROOT_MAPPING, ids=[cls.__name__ for cls in ROOT_MAPPING])
# def test_cache_consistency(cls):
# raw = cls(root=ROOT_MAPPING[cls])
# cached = raw.cached()
# fields = {x.name for x in raw._container.outputs} - {'ids', 'id', 'cached'}
#
# ids = raw.ids
# assert ids == cached.ids
# for i in ids:
# for field in fields:
# compare(getattr(raw, field)(i), getattr(cached, field)(i))


# TODO: find a package for this
Expand Down

0 comments on commit 5547483

Please sign in to comment.