Skip to content

Commit

Permalink
Merge pull request #47 from sot/pytest-ini
Browse files Browse the repository at this point in the history
Remove PYTEST_IGNORE_WARNINGS from runner and use pytest.ini instead
  • Loading branch information
javierggt authored Feb 3, 2023
2 parents 6d9420a + c9aa448 commit 0a00d7b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 43 deletions.
29 changes: 19 additions & 10 deletions testr/packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,16 +182,25 @@ def collect_tests():
else:
interpreter = None

test = {'file': test_file,
'status': status,
'interpreter': interpreter,
'out_dir': out_dir,
'regress_dir': regress_dir,
'packages_repo': opt.packages_repo,
'package': package,
'package_version': version,
'coverage': opt.coverage,
'coverage_config': opt.coverage_config}
test = {
'file': test_file,
'status': status,
'interpreter': interpreter,
'out_dir': out_dir,
'regress_dir': regress_dir,
'packages_repo': opt.packages_repo,
'package': package,
'package_version': version,
'coverage': opt.coverage,
'coverage_config': opt.coverage_config,
}

if test_file.endswith('.py'):
pytest_ini = in_dir / 'pytest.ini'
if not pytest_ini.exists():
pytest_ini = opt.root / 'pytest.ini'
if pytest_ini.exists():
test['pytest_ini'] = pytest_ini

tests[package].append(test)

Expand Down
42 changes: 9 additions & 33 deletions testr/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,6 @@
import os


# Pytest args for main() to ignore several warnings that show up regularly in
# testing but can be ignored.
PYTEST_IGNORE_WARNINGS = (
# See https://github.com/numpy/numpy/issues/11788 for why the numpy.ufunc
# warning is apparently OK.
'-Wignore:numpy.ufunc size changed:RuntimeWarning',

# Shows up in upstream packages including ipyparallel
'-Wignore:the imp module is deprecated in favour of importlib:DeprecationWarning',

# Shows up in setuptools_scm
'-Wignore:parse functions are required to provide a named:PendingDeprecationWarning',

# Shows up in sparkles from importing bleach
'-Wignore:Using or importing the ABCs:DeprecationWarning',

# Shows up in several places from importing PyTables
'-Wignore:`np.object` is a deprecated alias for the builtin `object`',

# This warning comes about when running with the latest version MarksupSafe (>=2.0) but an old
# version of Jinja2<3.0.
"-Wignore: 'soft_unicode' has been renamed to 'soft_str'",

# annie/telem.py:18
# (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes)
# is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the
# ndarray.
"-Wignore: Creating an ndarray from ragged nested sequences",
)


class TestError(Exception):
pass

Expand Down Expand Up @@ -134,8 +103,6 @@ def chdir(dirname=None):
if kwargs.pop('show_output', False) and '-s' not in args and '--capture' not in arg_names:
args = args + ('-s',)

args = args + PYTEST_IGNORE_WARNINGS

if 'TESTR_OUT_DIR' in os.environ and 'TESTR_FILE' in os.environ:
report_file = os.path.join(os.environ['TESTR_OUT_DIR'], f"{os.environ['TESTR_FILE']}.xml")
args += (f'--junit-xml={report_file}',)
Expand All @@ -145,6 +112,15 @@ def chdir(dirname=None):
# flight directory if tests fail running on installed package.
args = args + ('-p', 'no:cacheprovider')

pytest_ini = os.environ.get('TESTR_PYTEST_INI', None)
if pytest_ini is not None:
if os.path.exists(pytest_ini):
args += ('-c', os.path.abspath(pytest_ini))
else:
raise Exception(
f'Pytest config file does not exist (TESTR_PYTEST_INI={pytest_ini})'
)

if 'TESTR_ALLOW_HYPOTHESIS' not in os.environ:
# Disable autoload of hypothesis plugin which causes warnings due to
# trying to write to .hypothesis dir from the cwd of test runner. See
Expand Down

0 comments on commit 0a00d7b

Please sign in to comment.