Permalink
Browse files

Convert hamcrest to a single source base

* finalizes py25 deprecation
* [TravisCI] fixups for single-source, remove Jython and Python 2.5
* Enable coveralls
  • Loading branch information...
1 parent dab9933 commit aa4e6cd5703ae439a5193ab152eb359a789cb0f7 @offbyone offbyone committed Dec 31, 2013
View
@@ -0,0 +1,2 @@
+[run]
+source = hamcrest
View
@@ -1,52 +1,40 @@
language: python
python:
- - 2.5
- - 2.6
- - 2.7
- - 3.2
- - 3.3
- - pypy
+ - 2.6
+ - 2.7
+ - 3.2
+ - 3.3
+ - pypy
env:
matrix:
- NUMPY="true"
- NUMPY="false"
matrix:
- exclude:
- - python: pypy
- env: NUMPY="true"
- - python: jython2.5
- env: NUMPY="true"
-
- allow_failures:
- - python: jython2.5
- env: NUMPY="false"
+ exclude:
+ - python: pypy
+ env: NUMPY="true"
before_install:
- export PYTHON_EXE=python
- - export JYTHON_URL='http://downloads.sourceforge.net/project/jython/jython/2.5.2/jython_installer-2.5.2.jar?r=http%3A%2F%2Fwww.jython.org%2Fdownloads.html&ts=1338089844&use_mirror=iweb'
- export EASY_SETUP_URL='http://peak.telecommunity.com/dist/ez_setup.py'
- - if [[ $TRAVIS_PYTHON_VERSION == 'jython2.5' ]]; then wget $JYTHON_URL -O jython_installer.jar; java -jar jython_installer.jar -s -d $HOME/jython | tail -n 2; export PATH=$HOME/jython:$HOME/jython/bin:$PATH; jython -c print; export PYTHON_EXE=jython; fi
- - if [[ $TRAVIS_PYTHON_VERSION == 'jython2.5' ]]; then wget $EASY_SETUP_URL -O ez_setup.py; jython ez_setup.py; hash -r; easy_install pip; fi
install:
- - if [[ $TRAVIS_PYTHON_VERSION == '2.5' ]]; then pip install --use-mirrors unittest2; fi
- - if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then pip install --use-mirrors unittest2; fi
- - if [[ $TRAVIS_PYTHON_VERSION == "jython2.5" ]]; then pip install nose unittest2; fi
- - if [[ $NUMPY == "true" ]]; then pip install numpy; fi
- - pip install --use-mirrors 'pytest>=2.3.5' 'six'
- - "/usr/bin/yes | $PYTHON_EXE setup.py install 2>&1 | tail -n 2"
- # - pip install . --use-mirrors
+ - if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then pip install --use-mirrors unittest2; fi
+ - if [[ $NUMPY == "true" ]]; then pip install numpy; fi
+ - pip install --use-mirrors coveralls
+ - pip install --use-mirrors 'pytest>=2.3.5' 'pytest-cov>=1.6'
+ - pip install --use-mirrors -r requirements.txt
before_script:
- - if [[ $TRAVIS_PYTHON_VERSION == "jython2.5" ]]; then jython -c "print ''"; fi
- if [[ $TRAVIS_PYTHON_VERSION == "3.3" ]]; then export PYTHONHASHSEED=4; fi
+ - if [[ $TRAVIS_PYTHON_VERSION == "3.4" ]]; then export PYTHONHASHSEED=8; fi
script:
- # Must cd somewhere else so python3 doesn't get confused and run
- # the python2 code from the current directory instead of the installed
- # 2to3 version.
- - $PYTHON_EXE setup.py build
- - py.test -v
+ - $PYTHON_EXE setup.py develop
+ - py.test -v --cov hamcrest
+
+after_success:
+ - coveralls
View
@@ -10,6 +10,10 @@ PyHamcrest
.. image:: https://travis-ci.org/hamcrest/PyHamcrest.png?branch=master
:alt: Build Status
:target: https://travis-ci.org/hamcrest/PyHamcrest
+.. image:: https://coveralls.io/repos/hamcrest/PyHamcrest/badge.png?branch=master
+ :alt: Coverage
+ :target: https://coveralls.io/r/hamcrest/PyHamcrest?branch=master
+
Introduction
============
View
@@ -0,0 +1 @@
+six>=1.4
View
@@ -27,8 +27,8 @@ def read(fname):
fh.close()
extra_attributes = {}
-if sys.version_info >= (3,):
- extra_attributes['use_2to3'] = True
+# if sys.version_info >= (3,):
+# extra_attributes['use_2to3'] = True
params = dict(
name='PyHamcrest',
@@ -45,17 +45,18 @@ def read(fname):
package_dir = {'': 'src'},
provides=['hamcrest'],
long_description=read('README.rst'),
- install_requires=['setuptools'],
+ install_requires=['setuptools', 'six'],
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Console',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Natural Language :: English',
'Operating System :: OS Independent',
- 'Programming Language :: Python :: 2.5',
+ 'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
+ 'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.2',
'Programming Language :: Python :: 3.3',
'Topic :: Software Development',
@@ -1,5 +1,6 @@
-from core import *
-from library import *
+from __future__ import absolute_import
+from hamcrest.core import *
+from hamcrest.library import *
__version__ = "1.8.0"
__author__ = "Chris Rose"
@@ -1,5 +1,6 @@
-from assert_that import assert_that
-from core import *
+from __future__ import absolute_import
+from hamcrest.core.assert_that import assert_that
+from hamcrest.core.core import *
__author__ = "Jon Reid"
__copyright__ = "Copyright 2011 hamcrest.org"
@@ -1,5 +1,6 @@
-from matcher import Matcher
-from string_description import StringDescription
+from __future__ import absolute_import
+from hamcrest.core.matcher import Matcher
+from hamcrest.core.string_description import StringDescription
__author__ = "Jon Reid"
__copyright__ = "Copyright 2011 hamcrest.org"
@@ -1,13 +1,14 @@
-from description import Description
-from selfdescribingvalue import SelfDescribingValue
-from helpers.hasmethod import hasmethod
-
-import warnings
-
+from __future__ import absolute_import
__author__ = "Jon Reid"
__copyright__ = "Copyright 2011 hamcrest.org"
__license__ = "BSD, see License.txt"
+import warnings
+import six
+
+from hamcrest.core.description import Description
+from hamcrest.core.selfdescribingvalue import SelfDescribingValue
+from hamcrest.core.helpers.hasmethod import hasmethod
class BaseDescription(Description):
"""Base class for all :py:class:`~hamcrest.core.description.Description`
@@ -22,10 +23,12 @@ def append_text(self, text):
def append_description_of(self, value):
if hasmethod(value, 'describe_to'):
value.describe_to(self)
- elif isinstance(value, str):
- self.append_string_in_python_syntax(value)
- elif isinstance(value, unicode):
+ elif six.PY3 and isinstance(value, six.text_type):
self.append(repr(value))
+ elif isinstance(value, six.binary_type):
+ self.append_string_in_python_syntax(value)
+ elif isinstance(value, six.text_type):
+ self.append_string_in_python_syntax(value)
else:
description = str(value)
if description[:1] == '<' and description[-1:] == '>':
@@ -1,9 +1,10 @@
+from __future__ import absolute_import
__author__ = "Jon Reid"
__copyright__ = "Copyright 2011 hamcrest.org"
__license__ = "BSD, see License.txt"
-from matcher import Matcher
-from string_description import tostring
+from hamcrest.core.matcher import Matcher
+from hamcrest.core.string_description import tostring
class BaseMatcher(Matcher):
@@ -1,16 +1,17 @@
+from __future__ import absolute_import
"""Fundamental matchers of objects and values, and composite matchers."""
-from allof import all_of
-from anyof import any_of
-from described_as import described_as
-from is_ import is_
-from isanything import anything
-from isequal import equal_to
-from isinstanceof import instance_of
-from isnone import none, not_none
-from isnot import is_not
-from issame import same_instance
-from raises import calling, raises
+from hamcrest.core.core.allof import all_of
+from hamcrest.core.core.anyof import any_of
+from hamcrest.core.core.described_as import described_as
+from hamcrest.core.core.is_ import is_
+from hamcrest.core.core.isanything import anything
+from hamcrest.core.core.isequal import equal_to
+from hamcrest.core.core.isinstanceof import instance_of
+from hamcrest.core.core.isnone import none, not_none
+from hamcrest.core.core.isnot import is_not
+from hamcrest.core.core.issame import same_instance
+from hamcrest.core.core.raises import calling, raises
__author__ = "Jon Reid"
__copyright__ = "Copyright 2011 hamcrest.org"
@@ -1,10 +1,11 @@
+from __future__ import absolute_import
__author__ = "Jon Reid"
__copyright__ = "Copyright 2011 hamcrest.org"
__license__ = "BSD, see License.txt"
from hamcrest.core.base_matcher import BaseMatcher
from hamcrest.core.helpers.wrap_matcher import wrap_matcher, is_matchable_type
-from isinstanceof import instance_of
+from .isinstanceof import instance_of
class Is(BaseMatcher):
@@ -1,9 +1,10 @@
+from __future__ import absolute_import
__author__ = "Jon Reid"
__copyright__ = "Copyright 2011 hamcrest.org"
__license__ = "BSD, see License.txt"
from hamcrest.core.base_matcher import BaseMatcher
-from isnot import is_not
+from .isnot import is_not
class IsNone(BaseMatcher):
@@ -1,11 +1,12 @@
+from __future__ import absolute_import
__author__ = "Jon Reid"
__copyright__ = "Copyright 2011 hamcrest.org"
__license__ = "BSD, see License.txt"
from hamcrest.core.base_matcher import BaseMatcher, Matcher
from hamcrest.core.helpers.wrap_matcher import wrap_matcher, is_matchable_type
-from isequal import equal_to
-from isinstanceof import instance_of
+from .isequal import equal_to
+from .isinstanceof import instance_of
class IsNot(BaseMatcher):
@@ -1,3 +1,5 @@
+import six
+
from hamcrest.core.base_matcher import Matcher
from hamcrest.core.core.isequal import equal_to
@@ -23,7 +25,7 @@ def is_matchable_type(expected_type):
if isinstance(expected_type, type):
return True
- if type(expected_type) == types.ClassType:
+ if isinstance(expected_type, six.class_types):
return True
return False
@@ -1,4 +1,5 @@
-from selfdescribing import SelfDescribing
+from __future__ import absolute_import
+from .selfdescribing import SelfDescribing
__author__ = "Jon Reid"
__copyright__ = "Copyright 2011 hamcrest.org"
@@ -1,4 +1,5 @@
-from base_description import BaseDescription
+from __future__ import absolute_import
+from .base_description import BaseDescription
__author__ = "Jon Reid"
__copyright__ = "Copyright 2011 hamcrest.org"
@@ -1,11 +1,12 @@
+from __future__ import absolute_import
"""Library of Matcher implementations."""
from hamcrest.core import *
-from collection import *
-from integration import *
-from number import *
-from object import *
-from text import *
+from hamcrest.library.collection import *
+from hamcrest.library.integration import *
+from hamcrest.library.number import *
+from hamcrest.library.object import *
+from hamcrest.library.text import *
__author__ = "Jon Reid"
__copyright__ = "Copyright 2011 hamcrest.org"
@@ -52,4 +52,4 @@ def only_contains(*items):
matchers = []
for item in items:
matchers.append(wrap_matcher(item))
- return IsSequenceOnlyContaining(apply(any_of, matchers))
+ return IsSequenceOnlyContaining(any_of(*matchers))
@@ -1,6 +1,7 @@
+from __future__ import absolute_import
"""Utilities for integrating Hamcrest with other libraries."""
-from match_equality import match_equality
+from .match_equality import match_equality
__author__ = "Jon Reid"
__copyright__ = "Copyright 2011 hamcrest.org"
@@ -1,7 +1,8 @@
+from __future__ import absolute_import
"""Matchers that perform numeric comparisons."""
-from iscloseto import close_to
-from ordering_comparison import greater_than, greater_than_or_equal_to, less_than, less_than_or_equal_to
+from .iscloseto import close_to
+from .ordering_comparison import greater_than, greater_than_or_equal_to, less_than, less_than_or_equal_to
__author__ = "Jon Reid"
__copyright__ = "Copyright 2011 hamcrest.org"
@@ -1,3 +1,4 @@
+import six
from hamcrest.core.base_matcher import BaseMatcher
from math import fabs
@@ -9,7 +10,7 @@
def isnumeric(value):
"""Confirm that 'value' can be treated numerically; duck-test accordingly
"""
- if isinstance(value, (int, float, complex, long)):
+ if isinstance(value, (float, complex) + six.integer_types):
return True
try:
@@ -1,8 +1,9 @@
+from __future__ import absolute_import
"""Matchers that inspect objects and classes."""
-from haslength import has_length
-from hasproperty import has_property, has_properties
-from hasstring import has_string
+from .haslength import has_length
+from .hasproperty import has_property, has_properties
+from .hasstring import has_string
__author__ = "Jon Reid"
__copyright__ = "Copyright 2011 hamcrest.org"
@@ -1,12 +1,13 @@
+from __future__ import absolute_import
"""Matchers that perform text comparisons."""
-from isequal_ignoring_case import equal_to_ignoring_case
-from isequal_ignoring_whitespace import equal_to_ignoring_whitespace
-from stringcontains import contains_string
-from stringendswith import ends_with
-from stringstartswith import starts_with
-from stringmatches import matches_regexp
-from stringcontainsinorder import string_contains_in_order
+from .isequal_ignoring_case import equal_to_ignoring_case
+from .isequal_ignoring_whitespace import equal_to_ignoring_whitespace
+from .stringcontains import contains_string
+from .stringendswith import ends_with
+from .stringstartswith import starts_with
+from .stringmatches import matches_regexp
+from .stringcontainsinorder import string_contains_in_order
__author__ = "Jon Reid"
__copyright__ = "Copyright 2011 hamcrest.org"
Oops, something went wrong.

0 comments on commit aa4e6cd

Please sign in to comment.