Skip to content

Commit

Permalink
Don't error if pytest-astropy-header is not installed
Browse files Browse the repository at this point in the history
  • Loading branch information
astrofrog committed Oct 26, 2019
1 parent b0a84f6 commit f380664
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
6 changes: 5 additions & 1 deletion astropy/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
import builtins
import tempfile

from pytest_astropy_header.display import PYTEST_HEADER_MODULES
try:
from pytest_astropy_header.display import PYTEST_HEADER_MODULES
except ImportError:
PYTEST_HEADER_MODULES = {}

from astropy.tests.helper import enable_deprecations_as_exceptions

try:
Expand Down
4 changes: 2 additions & 2 deletions astropy/tests/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,14 @@ def _generate_args(self, **kwargs):
"""

_required_dependancies = ['pytest', 'pytest_remotedata', 'pytest_doctestplus']
_required_dependencies = ['pytest', 'pytest_remotedata', 'pytest_doctestplus', 'pytest_astropy_header']
_missing_dependancy_error = "Test dependencies are missing. You should install the 'pytest-astropy' package."

@classmethod
def _has_test_dependencies(cls): # pragma: no cover
# Using the test runner will not work without these dependencies, but
# pytest-openfiles is optional, so it's not listed here.
for module in cls._required_dependancies:
for module in cls._required_dependencies:
spec = find_spec(module)
# Checking loader accounts for packages that were uninstalled
if spec is None or spec.loader is None:
Expand Down
6 changes: 5 additions & 1 deletion conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
import pkg_resources
import tempfile

from pytest_astropy_header.display import PYTEST_HEADER_MODULES
try:
from pytest_astropy_header.display import PYTEST_HEADER_MODULES
except ImportError:
PYTEST_HEADER_MODULES = {}

import astropy

if find_spec('asdf') is not None:
Expand Down

0 comments on commit f380664

Please sign in to comment.