Skip to content

Commit

Permalink
Move data_directory fixture to toplevel conftest
Browse files Browse the repository at this point in the history
This is the default where [datamgr](https://github.com/ibis-
project/ibis/blob/master/ci/datamgr.py#L208) initializes the SQLite
db.

Author: Krisztián Szűcs <szucs.krisztian@gmail.com>

Closes #1581 from kszucs/sqlite_default_path and squashes the following commits:

eeef5ae [Krisztián Szűcs] move data_directory fixture to top level conftest
  • Loading branch information
kszucs authored and cpcloud committed Aug 8, 2018
1 parent 48d531a commit acdfc3d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 20 deletions.
18 changes: 18 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import fnmatch
import os
import sys
import pytest

from ibis.compat import Path


collect_ignore = ['setup.py']

Expand All @@ -11,3 +15,17 @@
for filename in filenames:
if fnmatch.fnmatch(filename, '*.py'):
collect_ignore.append(os.path.join(root, filename))


@pytest.fixture(scope='session')
def data_directory():
root = Path(__file__).absolute().parent

default = root / 'ci' / 'ibis-testing-data'
datadir = os.environ.get('IBIS_TEST_DATA_DIRECTORY', default)
datadir = Path(datadir)

if not datadir.exists():
pytest.skip('test data directory not found')

return datadir
7 changes: 3 additions & 4 deletions ibis/sql/sqlite/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@


@pytest.fixture(scope='module')
def dbpath():
# If we haven't defined an environment variable with the path of the SQLite
# database, assume it's in $PWD
path = os.environ.get('IBIS_TEST_SQLITE_DATABASE', 'ibis_testing.db')
def dbpath(data_directory):
default = str(data_directory / 'ibis_testing.db')
path = os.environ.get('IBIS_TEST_SQLITE_DATABASE', default)
if not os.path.exists(path):
pytest.skip('SQLite testing db {} does not exist'.format(path))
else:
Expand Down
16 changes: 0 additions & 16 deletions ibis/tests/all/conftest.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import os
import sys
import pytest

from ibis.compat import Path
from ibis.tests.backends import (Csv, Parquet, Pandas,
SQLite, Postgres, MySQL, MapD,
Clickhouse, Impala, BigQuery)
Expand All @@ -26,20 +24,6 @@
params_backend.append(pytest.param(MapD, marks=pytest.mark.mapd))


@pytest.fixture(scope='session')
def data_directory():
root = Path(__file__).absolute().parents[3]

default = root / 'ci' / 'ibis-testing-data'
datadir = os.environ.get('IBIS_TEST_DATA_DIRECTORY', default)
datadir = Path(datadir)

if not datadir.exists():
pytest.skip('test data directory not found')

return datadir


@pytest.fixture(params=params_backend, scope='session')
def backend(request, data_directory):
return request.param(data_directory)
Expand Down

0 comments on commit acdfc3d

Please sign in to comment.