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

chore: Transition to src/ layout #1099

Merged
merged 7 commits into from
Nov 11, 2024
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
7 changes: 0 additions & 7 deletions MANIFEST.in

This file was deleted.

109 changes: 0 additions & 109 deletions bids/layout/tests/conftest.py

This file was deleted.

7 changes: 0 additions & 7 deletions bids/tests/utils.py

This file was deleted.

6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ pybids = "bids.cli:cli"
[tool.versioneer]
VCS = "git"
style = "pep440-pre"
versionfile_source = "bids/_version.py"
versionfile_source = "src/bids/_version.py"
versionfile_build = "bids/_version.py"

[tool.coverage.run]
branch = true
source = ["bids/*"]
source = ["src/bids/*"]
omit = [
"*/setup.py",
"*/external/*",
Expand All @@ -95,4 +95,4 @@ omit = [
]

[tool.coverage.report]
include = ["bids/*"]
include = ["src/bids/*"]
7 changes: 0 additions & 7 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
[metadata]
platforms = OS Independent

[options]
packages = find:
include_package_data = True

[codespell]
skip = ./.git,external,versioneer.py,_version.py
ignore-words = .github/codespell_ignore_words.txt
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 15 additions & 1 deletion bids/conftest.py → src/bids/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
def bids_examples():
examples_dir = Path(os.getenv(
"BIDS_EXAMPLES",
Path(__file__).absolute().parent.parent / "bids-examples"
Path(__file__).absolute().parent.parent.parent / "bids-examples"
))

if not Path.is_dir(examples_dir / "ds001"):
Expand All @@ -50,3 +50,17 @@
"Override default location with BIDS_EXAMPLES environment variable."
)
return examples_dir

@pytest.fixture(scope='session')
def tests_dir():
test_dir = Path(os.getenv(
"PYBIDS_TEST_DATA",
Path(__file__).absolute().parent.parent.parent / "tests"
))

if not Path.is_dir(test_dir / "data"):
pytest.skip(

Check warning on line 62 in src/bids/conftest.py

View check run for this annotation

Codecov / codecov/patch

src/bids/conftest.py#L62

Added line #L62 was not covered by tests
f"BIDS examples missing from {test_dir}. "
"Override default location with PYBIDS_TEST_DATA environment variable."
)
return test_dir
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.
103 changes: 103 additions & 0 deletions src/bids/layout/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
from os.path import join

import pytest

from bids.layout import BIDSLayout


# Fixture uses in the rest of the tests
@pytest.fixture(scope="session")
def layout_7t_trt(tests_dir):
return BIDSLayout(tests_dir / 'data' / '7t_trt')


@pytest.fixture(scope="session")
def layout_7t_trt_relpath(tests_dir):
return BIDSLayout(tests_dir / 'data' / '7t_trt', absolute_paths=False)


@pytest.fixture(scope="session")
def layout_ds005(tests_dir):
return BIDSLayout(tests_dir / 'data' / 'ds005')


@pytest.fixture(scope="session")
def layout_ds005_no_validate(tests_dir):
return BIDSLayout(tests_dir / 'data' / 'ds005', validate=False)


@pytest.fixture(scope="session")
def layout_ds117(tests_dir):
return BIDSLayout(tests_dir / 'data' / 'ds000117')


@pytest.fixture(scope="session")
def layout_ds005_derivs(tests_dir):
data_dir = tests_dir / 'data' / 'ds005'
layout = BIDSLayout(data_dir)
deriv_dir = join(data_dir, 'derivatives', 'events')
layout.add_derivatives(deriv_dir)
return layout


@pytest.fixture(scope="session")
def layout_ds005_deriv_dummy_vxxx(tests_dir):
data_dir = tests_dir / 'data' / 'ds005'
layout = BIDSLayout(data_dir)
deriv_dir = tests_dir / 'data' / 'ds005_derivs' / 'dummy-vx.x.x'
layout.add_derivatives(deriv_dir)
return layout


@pytest.fixture(scope="session")
def layout_ds005_deriv_both_dummies(tests_dir):
data_dir = tests_dir / 'data' / 'ds005'
layout = BIDSLayout(data_dir)
deriv_dir1 = tests_dir / 'data' / 'ds005_derivs' / 'dummy-vx.x.x'
deriv_dir2 = tests_dir / 'data' / 'ds005_derivs' / 'dummy'
layout.add_derivatives([deriv_dir1, deriv_dir2])
return layout


@pytest.fixture(scope="session")
def db_dir(tmpdir_factory):
fn = tmpdir_factory.mktemp("data")
return fn


@pytest.fixture(scope="session",
params=[None, "bidsdb", "bidsdb"])
def layout_ds005_multi_derivs(tests_dir, request, db_dir):
data_dir = tests_dir / 'data' / 'ds005'
database_path = str(db_dir / request.param) if request.param else None

layout = BIDSLayout(data_dir,
database_path=database_path)
deriv_dir1 = tests_dir / 'data' / 'ds005_derivs' / 'dummy'
deriv_dir2 = join(data_dir, 'derivatives', 'events')
layout.add_derivatives([deriv_dir1, deriv_dir2])
return layout

@pytest.fixture(scope="session")
def layout_ds005_deriv_name_collision(tests_dir, request):
data_dir = tests_dir / 'data' / 'ds005'

Check warning on line 83 in src/bids/layout/tests/conftest.py

View check run for this annotation

Codecov / codecov/patch

src/bids/layout/tests/conftest.py#L83

Added line #L83 was not covered by tests

layout = BIDSLayout(data_dir)
deriv_dir1 = tests_dir / 'data' / 'ds005_derivs' / 'dummy'
deriv_dir2 = join(data_dir, 'derivatives', 'events')
layout.add_derivatives([deriv_dir1, deriv_dir2])
return layout

Check warning on line 89 in src/bids/layout/tests/conftest.py

View check run for this annotation

Codecov / codecov/patch

src/bids/layout/tests/conftest.py#L85-L89

Added lines #L85 - L89 were not covered by tests


@pytest.fixture(
scope="session", params=[None, "bidsdb-synth", "bidsdb-synth"])
def layout_synthetic(tests_dir, request, db_dir):
path = tests_dir / 'data' / 'synthetic'
database_path = str(db_dir / request.param) if request.param else None
return BIDSLayout(path, derivatives=True,
database_path=database_path)

@pytest.fixture(scope="session")
def layout_synthetic_nodb(tests_dir, request, db_dir):
path = tests_dir / 'data' / 'synthetic'
return BIDSLayout(path, derivatives=True)
File renamed without changes.
Loading