-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from bmorris3/tests
Tests
- Loading branch information
Showing
12 changed files
with
105 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,55 @@ | ||
# this contains imports plugins that configure py.test for astropy tests. | ||
# by importing them here in conftest.py they are discoverable by py.test | ||
# no matter how it is invoked within the source tree. | ||
|
||
from astropy.tests.pytest_plugins import * | ||
|
||
## Uncomment the following line to treat all DeprecationWarnings as | ||
## exceptions. For Astropy v2.0 or later, there are 2 additional keywords, | ||
## as follow (although default should work for most cases). | ||
## To ignore some packages that produce deprecation warnings on import | ||
## (in addition to 'compiler', 'scipy', 'pygments', 'ipykernel', and | ||
## 'setuptools'), add: | ||
## modules_to_ignore_on_import=['module_1', 'module_2'] | ||
## To ignore some specific deprecation warning messages for Python version | ||
## MAJOR.MINOR or later, add: | ||
## warnings_to_ignore_by_pyver={(MAJOR, MINOR): ['Message to ignore']} | ||
# enable_deprecations_as_exceptions() | ||
|
||
## Uncomment and customize the following lines to add/remove entries from | ||
## the list of packages for which version numbers are displayed when running | ||
## the tests. Making it pass for KeyError is essential in some cases when | ||
## the package uses other astropy affiliated packages. | ||
# try: | ||
# PYTEST_HEADER_MODULES['Astropy'] = 'astropy' | ||
# PYTEST_HEADER_MODULES['scikit-image'] = 'skimage' | ||
# del PYTEST_HEADER_MODULES['h5py'] | ||
# except (NameError, KeyError): # NameError is needed to support Astropy < 1.0 | ||
# pass | ||
|
||
## Uncomment the following lines to display the version number of the | ||
## package rather than the version number of Astropy in the top line when | ||
## running the tests. | ||
# import os | ||
# | ||
## This is to figure out the package version, rather than | ||
## using Astropy's | ||
# try: | ||
# from .version import version | ||
# except ImportError: | ||
# version = 'dev' | ||
# | ||
# try: | ||
# packagename = os.path.basename(os.path.dirname(__file__)) | ||
# TESTED_VERSIONS[packagename] = version | ||
# except NameError: # Needed to support Astropy <= 1.0.0 | ||
# pass | ||
# also save a copy of the astropy hooks so we can use them below when | ||
# overriding | ||
from astropy.tests import pytest_plugins as astropy_pytest_plugins | ||
|
||
import warnings | ||
|
||
import os | ||
|
||
# This is to figure out the affiliated package version, rather than | ||
# using Astropy's | ||
try: | ||
from .version import version | ||
except ImportError: | ||
version = 'dev' | ||
|
||
packagename = os.path.basename(os.path.dirname(__file__)) | ||
TESTED_VERSIONS[packagename] = version | ||
|
||
|
||
# Comment out this line to avoid deprecation warnings being raised as | ||
# exceptions | ||
enable_deprecations_as_exceptions() | ||
|
||
# Define list of packages for which to display version numbers in the test log | ||
try: | ||
PYTEST_HEADER_MODULES['Astropy'] = 'astropy' | ||
del PYTEST_HEADER_MODULES['h5py'] | ||
except KeyError: | ||
pass | ||
|
||
|
||
def pytest_configure(config): | ||
if hasattr(astropy_pytest_plugins, 'pytest_configure'): | ||
# sure ought to be true right now, but always possible it will change in | ||
# future versions of astropy | ||
astropy_pytest_plugins.pytest_configure(config) | ||
|
||
# activate image comparison tests only if the dependencies needed are installed: | ||
# matplotlib, nose, pytest-mpl | ||
try: | ||
import matplotlib | ||
import nose # needed for the matplotlib testing tools | ||
HAS_MATPLOTLIB_AND_NOSE = True | ||
except ImportError: | ||
HAS_MATPLOTLIB_AND_NOSE = False | ||
|
||
if HAS_MATPLOTLIB_AND_NOSE and config.pluginmanager.hasplugin('mpl'): | ||
pass | ||
# TODO: turn image comparison tests back on once this issue is figured out: | ||
# https://github.com/astropy/astroplan/pull/104#issuecomment-137734007 | ||
# config.option.mpl = True | ||
# config.option.mpl_baseline_path = 'astroplan/plots/tests/baseline_images' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
def get_package_data(): | ||
"""Declare aesop datafiles""" | ||
pdata = dict() | ||
pdata['aesop.tests'] = ['coveragerc'] | ||
return pdata |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +0,0 @@ | ||
# Licensed under a 3-clause BSD style license - see LICENSE.rst | ||
""" | ||
This module contains package tests. | ||
""" | ||
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from __future__ import (absolute_import, division, print_function, | ||
unicode_literals) | ||
|
||
|
||
import numpy as np | ||
import astropy.units as u | ||
import pytest | ||
from astropy.units import UnitsError | ||
|
||
from ..spectra import Spectrum1D | ||
|
||
|
||
def test_constructor(): | ||
wl = np.linspace(3000, 4000) * u.Angstrom | ||
f = 1 + 0.1 * np.random.randn() | ||
example = Spectrum1D(wavelength=wl, flux=f) | ||
|
||
# raise an error if there is no unit on the wavelength | ||
with pytest.raises(TypeError): | ||
example = Spectrum1D(wavelength=[0, 1, 2, 3], flux=f) | ||
|
||
# raise an error if the wavelength unit is not a unit of length | ||
with pytest.raises(UnitsError): | ||
example = Spectrum1D(wavelength=u.Quantity([0, 1, 2, 3], unit=u.day), | ||
flux=f) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ astropy >= 1.3 | |
sphinx-automodapi | ||
scipy | ||
astroquery | ||
specutils |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters