Page MenuHomePhabricator

Tests fail to initialize if six is missing
Closed, ResolvedPublic

Description

I installed a new version of Python and forgot to install six. Now when I did python setup.py test I got:

xzise@localhost:~/Programms/core$ python setup.py test
running test
running egg_info
writing pywikibot.egg-info/PKG-INFO
writing dependency_links to pywikibot.egg-info/dependency_links.txt
writing top-level names to pywikibot.egg-info/top_level.txt
writing requirements to pywikibot.egg-info/requires.txt
reading manifest file 'pywikibot.egg-info/SOURCES.txt'
writing manifest file 'pywikibot.egg-info/SOURCES.txt'
running build_ext
max_retries reduced from 10 to 1 for tests
Disabled test modules (to run: python -m unittest ...):
  ui
Extra test modules (run after library, before scripts):
  exceptions, thread, timestamp, tk, wikistats
Skipping tests (to run: python -m unittest ...):
  {'textlib': ['test_interwiki_format']}
Traceback (most recent call last):
  File "setup.py", line 127, in <module>
    use_2to3=False
  File "/home/xzise/.pyenv/versions/3.4.2/lib/python3.4/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/home/xzise/.pyenv/versions/3.4.2/lib/python3.4/distutils/dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "/home/xzise/.pyenv/versions/3.4.2/lib/python3.4/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/home/xzise/.pyenv/versions/3.4.2/lib/python3.4/site-packages/setuptools/command/test.py", line 138, in run
    self.with_project_on_sys_path(self.run_tests)
  File "/home/xzise/.pyenv/versions/3.4.2/lib/python3.4/site-packages/setuptools/command/test.py", line 118, in with_project_on_sys_path
    func()
  File "/home/xzise/.pyenv/versions/3.4.2/lib/python3.4/site-packages/setuptools/command/test.py", line 164, in run_tests
    testLoader = cks
  File "/home/xzise/.pyenv/versions/3.4.2/lib/python3.4/unittest/main.py", line 92, in __init__
    self.parseArgs(argv)
  File "/home/xzise/.pyenv/versions/3.4.2/lib/python3.4/unittest/main.py", line 139, in parseArgs
    self.createTests()
  File "/home/xzise/.pyenv/versions/3.4.2/lib/python3.4/unittest/main.py", line 146, in createTests
    self.module)
  File "/home/xzise/.pyenv/versions/3.4.2/lib/python3.4/unittest/loader.py", line 146, in loadTestsFromNames
    suites = [self.loadTestsFromName(name, module) for name in names]
  File "/home/xzise/.pyenv/versions/3.4.2/lib/python3.4/unittest/loader.py", line 146, in <listcomp>
    suites = [self.loadTestsFromName(name, module) for name in names]
  File "/home/xzise/.pyenv/versions/3.4.2/lib/python3.4/unittest/loader.py", line 131, in loadTestsFromName
    test = obj()
  File "/home/xzise/Programms/core/tests/__init__.py", line 159, in collector
    discovered = loader.loadTestsFromName(module_class_name)
  File "/home/xzise/.pyenv/versions/3.4.2/lib/python3.4/unittest/loader.py", line 114, in loadTestsFromName
    parent, obj = obj, getattr(obj, part)
AttributeError: 'module' object has no attribute 'textlib_tests'
<class 'AttributeError'>
CRITICAL: Waiting for 1 network thread(s) to finish. Press ctrl-c to abort

But obviously the file was there. Luckily I remembered someone had the same problem I could look into my IRC log and found that I suggested to do python pwb.py tests/textlib_tests.py and only then I got the actual error:

xzise@localhost:~/Programms/core$ python pwb.py tests/textlib_tests.py
max_retries reduced from 10 to 1 for tests
Traceback (most recent call last):
  File "pwb.py", line 221, in <module>
    run_python_file(filename, argv, argvu, file_package)
  File "pwb.py", line 80, in run_python_file
    exec(compile(source, filename, "exec"), main_mod.__dict__)
  File "./tests/textlib_tests.py", line 18, in <module>
    from tests.aspects import unittest, TestCase, DefaultDrySiteTestCase
  File "/home/xzise/Programms/core/tests/aspects.py", line 848, in <module>
    import six
ImportError: No module named 'six'
<class 'ImportError'>
CRITICAL: Waiting for 1 network thread(s) to finish. Press ctrl-c to abort

If possible the tests should require six and install it before, or stop (with a sensible warning) before, or skip those entries. At least with Python 3.5 we might get a more detailed error message: http://bugs.python.org/issue7559 .

Event Timeline

XZise raised the priority of this task from to Needs Triage.
XZise updated the task description. (Show Details)
XZise added projects: Pywikibot, Pywikibot-tests.
XZise subscribed.
gerritbot subscribed.

Change 187589 had a related patch set uploaded (by Merlijn van Deen):
Add 'six' as Python 3 test dependency

https://gerrit.wikimedia.org/r/187589

Patch-For-Review

Change 187589 merged by jenkins-bot:
Add 'six' as Python 3 test dependency

https://gerrit.wikimedia.org/r/187589

jayvdb claimed this task.