Skip to content
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,15 @@ matrix:

# Now try with all optional dependencies the latest 3.x and on 2.7.
# (with latest numpy). We also test the two latest matplotlib versions
# for the image tests.
# for the image tests, and with the system rather than build-in pytest.
- os: linux
env: PYTHON_VERSION=2.7 SETUP_CMD='test --remote-data=astropy -a "--mpl"'
CONDA_DEPENDENCIES=$CONDA_ALL_DEPENDENCIES
PIP_DEPENDENCIES='jplephem mock pytest-mpl'
LC_CTYPE=C.ascii LC_ALL=C
NUMPY_VERSION=1.10
MATPLOTLIB_VERSION=1.4
ASTROPY_USE_SYSTEM_PYTEST=1

- os: linux
env: SETUP_CMD='test --coverage --remote-data=astropy -a "--mpl"'
Expand All @@ -95,6 +96,7 @@ matrix:
LC_CTYPE=C.ascii LC_ALL=C
CFLAGS='-ftest-coverage -fprofile-arcs -fno-inline-functions -O0'
MATPLOTLIB_VERSION=1.5
ASTROPY_USE_SYSTEM_PYTEST=1

# Try pre-release version of Numpy without optional dependencies
- os: linux
Expand Down
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ environment:
NUMPY_VERSION: "stable"
- PYTHON_VERSION: "3.5"
NUMPY_VERSION: "stable"
ASTROPY_USE_SYSTEM_PYTEST: 1

matrix:
fast_finish: true
Expand Down
17 changes: 4 additions & 13 deletions astropy/tests/pytest_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ def collect(self):

# uses internal doctest module parsing mechanism
finder = DocTestFinderPlus()
runner = doctest.DebugRunner(verbose=False, optionflags=opts)
runner = doctest.DebugRunner(verbose=False, optionflags=opts,
checker=AstropyOutputChecker())
for test in finder.find(module):
if test.examples: # skip empty doctests
if config.getvalue("remote_data") != 'any':
Expand All @@ -190,21 +191,11 @@ def collect(self):
yield doctest_plugin.DoctestItem(
test.name, self, runner, test)

# This is for py.test prior to 2.4.0
def runtest(self):
return

class DocTestTextfilePlus(doctest_plugin.DoctestTextfile):
class DocTestTextfilePlus(doctest_plugin.DoctestItem, pytest.Module):
def runtest(self):
# satisfy `FixtureRequest` constructor...
self.funcargs = {}
try:
self._fixtureinfo = doctest_plugin.FuncFixtureInfo((), [], {})
fixture_request = doctest_plugin.FixtureRequest(self)
except AttributeError: # pytest >= 2.8.0
python_plugin = config.pluginmanager.getplugin('python')
self._fixtureinfo = python_plugin.FuncFixtureInfo((), [], {})
fixture_request = python_plugin.FixtureRequest(self)
fixture_request = doctest_plugin._setup_fixtures(self)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is so elegant. How did you find this? 👍

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Staring at the _pytest/doctest.py source code... Which also convinced me the whole thing can be done more elegantly (probably by subclassing DoctestItem, as you suggested elsewhere).

But happy enough if things work for now...


failed, tot = doctest.testfile(
str(self.fspath), module_relative=False,
Expand Down
20 changes: 13 additions & 7 deletions astropy/tests/tests/test_runner.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
from astropy.tests.runner import TestRunner, TestRunnerBase, keyword
# Renamed these imports so that them being in the namespace will not
# cause pytest 3 to discover them as tests and then complain that
# they have __init__ defined.
from astropy.tests.runner import TestRunner as _TestRunner
from astropy.tests.runner import TestRunnerBase as _TestRunnerBase

from astropy.tests.runner import keyword
from astropy.tests.helper import pytest


def test_disable_kwarg():
class no_remote_data(TestRunner):
class no_remote_data(_TestRunner):
@keyword()
def remote_data(self, remote_data, kwargs):
return NotImplemented
Expand All @@ -14,13 +20,13 @@ def remote_data(self, remote_data, kwargs):


def test_wrong_kwarg():
r = TestRunner('.')
r = _TestRunner('.')
with pytest.raises(TypeError):
r.run_tests(spam='eggs')


def test_invalid_kwarg():
class bad_return(TestRunnerBase):
class bad_return(_TestRunnerBase):
@keyword()
def remote_data(self, remote_data, kwargs):
return 'bob'
Expand All @@ -31,7 +37,7 @@ def remote_data(self, remote_data, kwargs):


def test_new_kwarg():
class Spam(TestRunnerBase):
class Spam(_TestRunnerBase):
@keyword()
def spam(self, spam, kwargs):
return [spam]
Expand All @@ -44,7 +50,7 @@ def spam(self, spam, kwargs):


def test_priority():
class Spam(TestRunnerBase):
class Spam(_TestRunnerBase):
@keyword()
def spam(self, spam, kwargs):
return [spam]
Expand All @@ -61,7 +67,7 @@ def eggs(self, eggs, kwargs):


def test_docs():
class Spam(TestRunnerBase):
class Spam(_TestRunnerBase):
@keyword()
def spam(self, spam, kwargs):
"""
Expand Down