Skip to content
This repository was archived by the owner on Nov 11, 2024. It is now read-only.
This repository was archived by the owner on Nov 11, 2024. It is now read-only.

Astropy helpers break user-installed pytest #258

Description

@josePhoenix

Every so often I make the mistake of running pytest instead of python setup.py test. It seems like this should work, but instead I get errors collecting tests that seem to be related to the astropy helpers. Even though the file doesn't appear in the traceback below, it seems to come from imports in the conftest.py from the package template.

This also appears to bite unwary users of packages that use the template: http://stackoverflow.com/questions/31410723/error-using-pytest-tutorial

$ pytest
=============================================== test session starts ================================================
platform darwin -- Python 2.7.12, pytest-3.0.3, py-1.4.31, pluggy-0.4.0
rootdir: /Users/jlong/software/webbpsf, inifile: setup.cfg
collected 0 items / 1 errors

====================================================== ERRORS ======================================================
________________________________________________ ERROR collecting  _________________________________________________
../../homebrew/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/py-1.4.31-py2.7.egg/py/_path/common.py:332: in visit
    for x in Visitor(fil, rec, ignore, bf, sort).gen(self):
../../homebrew/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/py-1.4.31-py2.7.egg/py/_path/common.py:368: in gen
    if p.check(dir=1) and (rec is None or rec(p))])
../../homebrew/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_pytest/main.py:672: in _recurse
    ihook = self.gethookproxy(path)
../../homebrew/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_pytest/main.py:575: in gethookproxy
    my_conftestmodules = pm._getconftestmodules(fspath)
../../homebrew/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_pytest/config.py:314: in _getconftestmodules
    mod = self._importconftest(conftestpath)
../../homebrew/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_pytest/config.py:350: in _importconftest
    self.consider_conftest(mod)
../../homebrew/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_pytest/config.py:373: in consider_conftest
    if self.register(conftestmodule, name=conftestmodule.__file__):
../../homebrew/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_pytest/config.py:225: in register
    ret = super(PytestPluginManager, self).register(plugin, name)
../../homebrew/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py:371: in register
    hook._maybe_apply_history(hookimpl)
../../homebrew/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py:768: in _maybe_apply_history
    res = self._hookexec(self, [method], kwargs)
../../homebrew/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py:339: in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
../../homebrew/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py:334: in <lambda>
    _MultiCall(methods, kwargs, hook.spec_opts).execute()
../../homebrew/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py:614: in execute
    res = hook_impl.function(*args)
../../homebrew/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/astropy/tests/pytest_plugins.py:137: in pytest_configure
    if not config.getoption('remote_data'):
../../homebrew/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_pytest/config.py:1148: in getoption
    raise ValueError("no option named %r" % (name,))
E   ValueError: no option named u'remote_data'
============================================== pytest-warning summary ==============================================
WC1 None [pytest] section in setup.cfg files is deprecated, use [tool:pytest] instead.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
==================================== 1 pytest-warnings, 1 error in 1.62 seconds ====================================

Activity

  1. josePhoenix commented on Oct 11, 2016

    @josePhoenix
    Author

    Context: mperrin/webbpsf (si_wfe branch), astropy_helpers submodule at v1.2.

  2. pllim commented on Oct 11, 2016

    @pllim
    Member

    py.test should work (I notice you don't have the period in your command). But regardless there is another issue now, see astropy/astropy#5277 .

  3. josePhoenix commented on Oct 11, 2016

    @josePhoenix
    Author

    None of the examples in the docs have a period in the command. See http://docs.pytest.org/en/latest/. I believe that works as an alias for backwards compatibility.

  4. pllim commented on Oct 11, 2016

    @pllim
    Member

    If you don't need Astropy's test framework, try comment out from astropy.tests.pytest_plugins import * in your conftest.py and see if it stops complaining about "remote data".

  5. josePhoenix commented on Oct 11, 2016

    @josePhoenix
    Author

    Yes, the tests run without these customizations. I guess I should open an issue on Astropy? Or the package template?

  6. pllim commented on Oct 11, 2016

    @pllim
    Member

    The actual test runner lives in Astropy, so you should file an issue there. However, please try again with customization by downgrading your pytest to 2.x first, just to make sure you are not filing a duplicate of astropy/astropy#5277 (which we are already aware of but has no time/resource to address yet).

  7. josePhoenix commented on Oct 11, 2016

    @josePhoenix
    Author

    Okay, I've opened a new issue.

  8. embray commented on Oct 11, 2016

    @embray
    Member

    What this comes down to mostly is that Astropy includes its own test runner (wrapper, really, around py.test) that interacts in various ways with some of the test plugins (for various reasons that I'm too hazy on to enumerate off the top of my head). But if you don't run the tests with the test runner, but you use those plugins, then some of the plugins can break.

    Also astropy uses its own bundled version of py.test, and the test runner might not work with other versions.

  9. pllim commented on Oct 11, 2016

    @pllim
    Member

    @embray , perhaps your idea to split out the tests in astropy-dev would naturally resolve this issue?

  10. embray commented on Oct 11, 2016

    @embray
    Member

    It would help. I actually hadn't considered the aspect that Astropy is using a bundled py.test. If we split it out into a separate package we might want to consider also supporting a wider range of py.test versions (though maybe starting with the current version that's in astropy as a minimum).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions