Skip to content

Running tests directly from pytest is broken #6424

@drdavella

Description

@drdavella

Sorry to add to the stack of testing issues 😢 .

First of all, is this even technically supported? Issue #5402 suggests that I'm not the only person who has expected this to work, but I'm guessing I'm the only person who has tried it in a long time. If it is supported, it could be a potential solution to #6392 since all pytest functionality is available directly from the pytest interface.

Here's what I get when I try to run pytest (using version 3.1.3 for the record):

../miniconda3/envs/astropy-pytest/lib/python3.6/site-packages/_pytest/config.py:336: in _getconftestmodules
    return self._path2confmods[path]
E   KeyError: local('/home/ddavella/astropy/astropy')

During handling of the above exception, another exception occurred:
../miniconda3/envs/astropy-pytest/lib/python3.6/site-packages/_pytest/config.py:367: in _importconftest
    return self._conftestpath2mod[conftestpath]
E   KeyError: local('/home/ddavella/astropy/astropy/conftest.py')

During handling of the above exception, another exception occurred:
../miniconda3/envs/astropy-pytest/lib/python3.6/site-packages/py/_path/common.py:372: in visit
    for x in Visitor(fil, rec, ignore, bf, sort).gen(self):
../miniconda3/envs/astropy-pytest/lib/python3.6/site-packages/py/_path/common.py:410: in gen
    dirs = self.optsort([p for p in entries
../miniconda3/envs/astropy-pytest/lib/python3.6/site-packages/py/_path/common.py:411: in <listcomp>
    if p.check(dir=1) and (rec is None or rec(p))])
../miniconda3/envs/astropy-pytest/lib/python3.6/site-packages/_pytest/main.py:686: in _recurse
    ihook = self.gethookproxy(path)
../miniconda3/envs/astropy-pytest/lib/python3.6/site-packages/_pytest/main.py:590: in gethookproxy
    my_conftestmodules = pm._getconftestmodules(fspath)
../miniconda3/envs/astropy-pytest/lib/python3.6/site-packages/_pytest/config.py:350: in _getconftestmodules
    mod = self._importconftest(conftestpath)
../miniconda3/envs/astropy-pytest/lib/python3.6/site-packages/_pytest/config.py:386: in _importconftest
    self.consider_conftest(mod)
../miniconda3/envs/astropy-pytest/lib/python3.6/site-packages/_pytest/config.py:409: in consider_conftest
    self.register(conftestmodule, name=conftestmodule.__file__)
../miniconda3/envs/astropy-pytest/lib/python3.6/site-packages/_pytest/config.py:264: in register
    self.consider_module(plugin)
../miniconda3/envs/astropy-pytest/lib/python3.6/site-packages/_pytest/config.py:415: in consider_module
    self._import_plugin_specs(getattr(mod, 'pytest_plugins', []))
../miniconda3/envs/astropy-pytest/lib/python3.6/site-packages/_pytest/config.py:420: in _import_plugin_specs
    self.import_plugin(import_spec)
../miniconda3/envs/astropy-pytest/lib/python3.6/site-packages/_pytest/config.py:452: in import_plugin
    self.register(mod, modname)
../miniconda3/envs/astropy-pytest/lib/python3.6/site-packages/_pytest/config.py:258: in register
    ret = super(PytestPluginManager, self).register(plugin, name)
../miniconda3/envs/astropy-pytest/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py:371: in register
    hook._maybe_apply_history(hookimpl)
../miniconda3/envs/astropy-pytest/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py:768: in _maybe_apply_history
    res = self._hookexec(self, [method], kwargs)
../miniconda3/envs/astropy-pytest/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py:339: in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
../miniconda3/envs/astropy-pytest/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py:334: in <lambda>
    _MultiCall(methods, kwargs, hook.spec_opts).execute()
../miniconda3/envs/astropy-pytest/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py:614: in execute
    res = hook_impl.function(*args)
astropy/tests/pytest_doctestplus.py:187: in pytest_configure
    config.getini('doctest_rst') or config.option.doctest_rst),
E   AttributeError: 'CmdOptions' object has no attribute 'doctest_rst'

I can patch this by making a quick fix to lines 185-187 in astropy/tests/pytest_doctestplus.py:

    config.pluginmanager.register(                                              
         DoctestPlus(DocTestModulePlus, DocTestTextfilePlus, False),             
                     #config.getini('doctest_rst') or config.option.doctest_rst),
         'doctestplus') 

After this, the tests will run, but they cause hundreds of errors and warnings, and also seem to want to use all of the memory on my machine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions