[Checkins] [zopefoundation/persistent] a7eb12: Make test pass when run with 'tox'

GitHub noreply at github.com
Mon Aug 27 17:41:28 CEST 2018


  Branch: refs/heads/fix-tox
  Home:   https://github.com/zopefoundation/persistent
  Commit: a7eb124f2873ff2a7660f446f19ba21216c19ec8
      https://github.com/zopefoundation/persistent/commit/a7eb124f2873ff2a7660f446f19ba21216c19ec8
  Author: Marius Gedminas <marius at gedmin.as>
  Date:   2018-08-27 (Mon, 27 Aug 2018)

  Changed paths:
    M persistent/tests/test_docs.py

  Log Message:
  -----------
  Make test pass when run with 'tox'

I used to get failures like

    py27 runtests: commands[0] | zope-testrunner --test-path=.
    Test-module import failures:

    Module: persistent.tests.test_docs

    IOError: [Errno 2] No such file or directory: '/home/mg/src/zopefoundation/persistent/.tox/docs/api/cache.rst'

    Running zope.testrunner.layer.UnitTests tests:
      Set up zope.testrunner.layer.UnitTests in 0.000 seconds.
      Ran 524 tests with 0 failures, 1 errors and 0 skipped in 0.249 seconds.
    Tearing down left over layers:
      Tear down zope.testrunner.layer.UnitTests in 0.000 seconds.

    Test-modules with import problems:
      persistent.tests.test_docs
    ERROR: InvocationError for command '/home/mg/src/zopefoundation/persistent/.tox/py27/bin/zope-testrunner --test-path=.' (exited with code 1)

because adding a ../ at the end of the path is not the same as stripping
off the last path component when symlinks are involved!

    $ cd .tox && ./py27/bin/python
    >>> >>> from persistent.tests.test_docs import __file__
    >>> __file__
    '/home/mg/src/zopefoundation/persistent/.tox/py27/local/lib/python2.7/site-packages/persistent/tests/test_docs.pyc'

.tox/py27/local/lib is a symlink to /home/mg/src/zopefoundation/persistent/.tox/py27/lib
and so .tox/py27/local/lib/.. is pointing to .tox/py27, while
os.path.abspath() thinks it's pointing to .tox/py27/local.

    >>> import os
    >>> here = os.path.dirname(__file__)
    >>> while not os.path.exists(os.path.join(here, 'setup.py')): here = os.path.join(here, '..')
    ...
    >>> here
    '/home/mg/src/zopefoundation/persistent/.tox/py27/local/lib/python2.7/site-packages/persistent/tests/../../../../../../..'
    >>> os.path.abspath(here)
    '/home/mg/src/zopefoundation/persistent/.tox'
    >>> os.path.exists(os.path.join(here, 'setup.py'))
    True
    >>> os.path.exists(os.path.join(os.path.abspath(here), 'setup.py'))
    False
    >>> os.path.exists(os.path.abspath(os.path.join(here, 'setup.py')))
    False



      **NOTE:** This service has been marked for deprecation: https://developer.github.com/changes/2018-04-25-github-services-deprecation/

      Functionality will be removed from GitHub.com on January 31st, 2019.


More information about the checkins mailing list