zopefoundation / zope.testbrowser

Programmable browser for functional black-box tests
Other
21 stars 16 forks source link

Test suite fails (cannot import name pystone) #5

Closed nidico closed 11 years ago

nidico commented 11 years ago

Building zope.testbrowser on my Fedora 18 machine with python-2.7.3 and virtualenv-1.9.1 from PyPI fails, using the enclosed buildout. This came up in #4 originally. This is the full stack trace:

nico@pesto $ bin/test
Running zope.testrunner.layer.UnitTests tests:
  Set up zope.testrunner.layer.UnitTests in 0.000 seconds.

Failure in test /home/nico/src/zope.testbrowser/src/zope/testbrowser/README.txt
Failed doctest test for README.txt
  File "/home/nico/src/zope.testbrowser/src/zope/testbrowser/README.txt", line 0

----------------------------------------------------------------------
File "/home/nico/src/zope.testbrowser/src/zope/testbrowser/README.txt", line 119, in README.txt
Failed example:
    verifyObject(interfaces.IBrowser, browser)
Exception raised:
    Traceback (most recent call last):
      File "/usr/lib64/python2.7/doctest.py", line 1289, in __run
        compileflags, 1) in test.globs
      File "<doctest README.txt[20]>", line 1, in <module>
        verifyObject(interfaces.IBrowser, browser)
      File "/home/nico/src/zope.testbrowser/eggs/zope.interface-4.0.5-py2.7-linux-x86_64.egg/zope/interface/verify.py", line 105, in verifyObject
        return _verify(iface, candidate, tentative, vtype='o')
      File "/home/nico/src/zope.testbrowser/eggs/zope.interface-4.0.5-py2.7-linux-x86_64.egg/zope/interface/verify.py", line 55, in _verify
        attr = getattr(candidate, name)
      File "/home/nico/src/zope.testbrowser/src/zope/testbrowser/browser.py", line 299, in lastRequestPystones
        return self.timer.elapsedPystones
      File "/home/nico/src/zope.testbrowser/src/zope/testbrowser/browser.py", line 176, in elapsedPystones
        return self.elapsedSeconds * self.pystonesPerSecond
      File "/home/nico/src/zope.testbrowser/src/zope/testbrowser/browser.py", line 135, in pystonesPerSecond
        from test import pystone
    ImportError: cannot import name pystone
----------------------------------------------------------------------
File "/home/nico/src/zope.testbrowser/src/zope/testbrowser/README.txt", line 1380, in README.txt
Failed example:
    browser.lastRequestPystones < 10000 # really big number for safety
Exception raised:
    Traceback (most recent call last):
      File "/usr/lib64/python2.7/doctest.py", line 1289, in __run
        compileflags, 1) in test.globs
      File "<doctest README.txt[388]>", line 1, in <module>
        browser.lastRequestPystones < 10000 # really big number for safety
      File "/home/nico/src/zope.testbrowser/src/zope/testbrowser/browser.py", line 299, in lastRequestPystones
        return self.timer.elapsedPystones
      File "/home/nico/src/zope.testbrowser/src/zope/testbrowser/browser.py", line 176, in elapsedPystones
        return self.elapsedSeconds * self.pystonesPerSecond
      File "/home/nico/src/zope.testbrowser/src/zope/testbrowser/browser.py", line 135, in pystonesPerSecond
        from test import pystone
    ImportError: cannot import name pystone

  Ran 19 tests with 1 failures and 0 errors in 0.375 seconds.
Tearing down left over layers:
  Tear down zope.testrunner.layer.UnitTests in 0.000 seconds.
nidico commented 11 years ago

I'm not having this problem using the same setup on a Debian Squeeze VM.

mgedmin commented 11 years ago

Can you run bin/test --pdb, and then at the pdb prompt do

(pdb) !import test
(pdb) p test.__file__

And also show us the contents of the buildout-generated bin/test script?

nidico commented 11 years ago

Sure:

nico@pesto $ bin/test --pdb
Running zope.testrunner.layer.UnitTests tests:
  Set up zope.testrunner.layer.UnitTests in 0.000 seconds.

Error in test /home/nico/src/zope.testbrowser/src/zope/testbrowser/README.txt
Traceback (most recent call last):
  File "/usr/lib64/python2.7/doctest.py", line 2284, in debug
    runner.run(self._dt_test, clear_globs=False)
  File "/usr/lib64/python2.7/doctest.py", line 1774, in run
    r = DocTestRunner.run(self, test, compileflags, out, False)
  File "/usr/lib64/python2.7/doctest.py", line 1429, in run
    return self.__run(test, compileflags, out)
  File "/usr/lib64/python2.7/doctest.py", line 1343, in __run
    exc_info)
  File "/usr/lib64/python2.7/doctest.py", line 1780, in report_unexpected_exception
    raise UnexpectedException(test, example, exc_info)
UnexpectedException: <DocTest README.txt from /home/nico/src/zope.testbrowser/src/zope/testbrowser/README.txt:0 (408 examples)>

exceptions.ImportError:
cannot import name pystone
> /home/nico/src/zope.testbrowser/src/zope/testbrowser/browser.py(135)pystonesPerSecond()
-> from test import pystone
(Pdb) !import test
(Pdb) p test.__file__
'/usr/lib64/python2.7/test/__init__.pyc'
(Pdb)

bin/test:

#!/home/nico/src/zope.testbrowser/bin/python

import sys
sys.path[0:0] = [
    '/home/nico/src/zope.testbrowser/src',
    '/home/nico/src/zope.testbrowser/eggs/zope.testrunner-4.3.3-py2.7.egg',
    '/home/nico/src/zope.testbrowser/eggs/zope.interface-4.0.5-py2.7-linux-x86_64.egg',
    '/home/nico/src/zope.testbrowser/eggs/zope.exceptions-4.0.6-py2.7.egg',
    '/home/nico/src/zope.testbrowser/eggs/six-1.3.0-py2.7.egg',
    '/home/nico/src/zope.testbrowser/eggs/setuptools-0.6c12dev_r88846-py2.7.egg',
    '/home/nico/src/zope.testbrowser/eggs/WebTest-1.3.4-py2.7.egg',
    '/home/nico/src/zope.testbrowser/eggs/zope.testing-4.1.2-py2.7.egg',
    '/home/nico/src/zope.testbrowser/eggs/pytz-2013b-py2.7.egg',
    '/home/nico/src/zope.testbrowser/eggs/zope.schema-4.3.2-py2.7.egg',
    '/home/nico/src/zope.testbrowser/eggs/mechanize-0.2.5-py2.7.egg',
    '/home/nico/src/zope.testbrowser/eggs/WebOb-1.2.3-py2.7.egg',
    '/home/nico/src/zope.testbrowser/eggs/zope.event-4.0.2-py2.7.egg',
    ]

import zope.testrunner

if __name__ == '__main__':
    sys.exit(zope.testrunner.run((['--tests-pattern', '^f?tests$']) + [
        '--test-path', '/home/nico/src/zope.testbrowser/src',
        ]))
mgedmin commented 11 years ago

Ok, this looks like an issue with Fedora's Python packaging (they do not ship the test.pystone module in their main Python package), and nothing to do with zope.testbrowser.

yum install python-test and the tests should pass.

nidico commented 11 years ago

Confirmed! Thanks for looking into this!

bazz2 commented 8 years ago

ImportError: cannot import name pystone -> solution is yum install python-test. Thank you, it works~~

ramadivyasri commented 8 years ago

I'm facing the same issue: File "/usr/lib/python2.7/site-packages/dpkt/decorators.py", line 4, in from test import pystone ImportError: cannot import name pystone

But, yum install python-test did not resolve the issue. What else can be done?