Skip to content

Pint won't import on Python 2.6 unless the enviornment happens to include unittest2. Should be explicit. #387

@movermeyer

Description

@movermeyer

On Python 2.6 and pint 0.7.2:

>>> import pint
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/exactEarth/pint/env/lib/python2.6/site-packages/pint/__init__.py", line 19, in <module>
    from .unit import (UnitRegistry, LazyRegistry)
  File "/usr/local/exactEarth/pint/env/lib/python2.6/site-packages/pint/unit.py", line 27, in <module>
    from . import registry_helpers
  File "/usr/local/exactEarth/pint/env/lib/python2.6/site-packages/pint/registry_helpers.py", line 14, in <module>
    from .compat import string_types, zip_longest
  File "/usr/local/exactEarth/pint/env/lib/python2.6/site-packages/pint/compat/__init__.py", line 58, in <module>
    raise Exception("Testing Pint in Python 2.6 requires package 'unittest2'")
Exception: Testing Pint in Python 2.6 requires package 'unittest2'

Except it shouldn't fail since this dependency is only needed when running tests.

If we add it to the tests_require parameter of setup.py

Something like:

tests_require = ['unittest2 ; python_version < '2.7']

and move compatibility lookup into a testsuite/compat/init.py,

then users can import pint on Python 2.6 without having to manually specify additional dependencies in order for it to run.

Pull request coming soon.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions