import in plugin_base doesn't work on pypy

Issue #3406 resolved
Michael Bayer
repo owner created an issue
try:
    # unitttest has a SkipTest also but pytest doesn't
    # honor it unless nose is imported too...
    from nose import SkipTest
except ImportError:
    from _pytest.runner import Skipped as SkipTest

the _pytest thing doesn't work:

>>>> from _pytest.runner import Skipped as SkipTest
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/src/pypy-2.5.1-osx64/site-packages/_pytest/runner.py", line 7, in <module>
    import pytest
  File "/usr/local/src/pypy-2.5.1-osx64/site-packages/pytest.py", line 17, in <module>
    _preloadplugins() # to populate pytest.* namespace so help(pytest) works
  File "/usr/local/src/pypy-2.5.1-osx64/site-packages/_pytest/config.py", line 58, in _preloadplugins
    _preinit.append(get_plugin_manager())
  File "/usr/local/src/pypy-2.5.1-osx64/site-packages/_pytest/config.py", line 67, in get_plugin_manager
    pluginmanager.import_plugin(spec)
  File "/usr/local/src/pypy-2.5.1-osx64/site-packages/_pytest/core.py", line 318, in import_plugin
    mod = importplugin(modname)
  File "/usr/local/src/pypy-2.5.1-osx64/site-packages/_pytest/core.py", line 370, in importplugin
    __import__(importspec)
ImportError: No module named main

this then causes pypy setup.py test to fail:

Traceback (most recent call last):
  File "<builtin>/app_main.py", line 75, in run_toplevel
  File "setup.py", line 154, in <module>
    run_setup(False)
  File "setup.py", line 150, in run_setup
    **kwargs
  File "/usr/local/src/pypy-2.5.1-osx64/lib-python/2.7/distutils/core.py", line 151, in setup
    dist.run_commands()
  File "/usr/local/src/pypy-2.5.1-osx64/lib-python/2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/usr/local/src/pypy-2.5.1-osx64/lib-python/2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/usr/local/src/pypy-2.5.1-osx64/site-packages/setuptools/command/test.py", line 142, in run
    self.with_project_on_sys_path(self.run_tests)
  File "/usr/local/src/pypy-2.5.1-osx64/site-packages/setuptools/command/test.py", line 122, in with_project_on_sys_path
    func()
  File "/usr/local/src/pypy-2.5.1-osx64/site-packages/setuptools/command/test.py", line 163, in run_tests
    testRunner=self._resolve_as_ep(self.test_runner),
  File "/usr/local/src/pypy-2.5.1-osx64/lib-python/2.7/unittest/main.py", line 94, in __init__
    self.parseArgs(argv)
  File "/usr/local/src/pypy-2.5.1-osx64/lib-python/2.7/unittest/main.py", line 149, in parseArgs
    self.createTests()
  File "/usr/local/src/pypy-2.5.1-osx64/lib-python/2.7/unittest/main.py", line 158, in createTests
    self.module)
  File "/usr/local/src/pypy-2.5.1-osx64/lib-python/2.7/unittest/loader.py", line 130, in loadTestsFromNames
    suites = [self.loadTestsFromName(name, module) for name in names]
  File "/usr/local/src/pypy-2.5.1-osx64/lib-python/2.7/unittest/loader.py", line 100, in loadTestsFromName
    parent, obj = obj, getattr(obj, part)
AttributeError: 'module' object has no attribute 'testing'

we need to look at current pytest and see if there's a SkipTest we can use that doesn't require the weird import here

Comments (3)

  1. Log in to comment