Skip to content

Commit

Permalink
Convert hamcrest to a single source base
Browse files Browse the repository at this point in the history
* finalizes py25 deprecation
* [TravisCI] fixups for single-source, remove Jython and Python 2.5
* Enable coveralls
  • Loading branch information
offbyone committed Feb 23, 2014
1 parent dab9933 commit aa4e6cd
Show file tree
Hide file tree
Showing 30 changed files with 137 additions and 118 deletions.
2 changes: 2 additions & 0 deletions .coveragerc
@@ -0,0 +1,2 @@
[run]
source = hamcrest
50 changes: 19 additions & 31 deletions .travis.yml
@@ -1,52 +1,40 @@
language: python language: python


python: python:
- 2.5 - 2.6
- 2.6 - 2.7
- 2.7 - 3.2
- 3.2 - 3.3
- 3.3 - pypy
- pypy


env: env:
matrix: matrix:
- NUMPY="true" - NUMPY="true"
- NUMPY="false" - NUMPY="false"


matrix: matrix:
exclude: exclude:
- python: pypy - python: pypy
env: NUMPY="true" env: NUMPY="true"
- python: jython2.5
env: NUMPY="true"

allow_failures:
- python: jython2.5
env: NUMPY="false"


before_install: before_install:
- export PYTHON_EXE=python - 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' - 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: 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 == '2.6' ]]; then pip install --use-mirrors unittest2; fi - if [[ $NUMPY == "true" ]]; then pip install numpy; fi
- if [[ $TRAVIS_PYTHON_VERSION == "jython2.5" ]]; then pip install nose unittest2; fi - pip install --use-mirrors coveralls
- if [[ $NUMPY == "true" ]]; then pip install numpy; fi - pip install --use-mirrors 'pytest>=2.3.5' 'pytest-cov>=1.6'
- pip install --use-mirrors 'pytest>=2.3.5' 'six' - pip install --use-mirrors -r requirements.txt
- "/usr/bin/yes | $PYTHON_EXE setup.py install 2>&1 | tail -n 2"
# - pip install . --use-mirrors


before_script: 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.3" ]]; then export PYTHONHASHSEED=4; fi
- if [[ $TRAVIS_PYTHON_VERSION == "3.4" ]]; then export PYTHONHASHSEED=8; fi


script: script:
# Must cd somewhere else so python3 doesn't get confused and run - $PYTHON_EXE setup.py develop
# the python2 code from the current directory instead of the installed - py.test -v --cov hamcrest
# 2to3 version.
- $PYTHON_EXE setup.py build after_success:
- py.test -v - coveralls
4 changes: 4 additions & 0 deletions README.rst
Expand Up @@ -10,6 +10,10 @@ PyHamcrest
.. image:: https://travis-ci.org/hamcrest/PyHamcrest.png?branch=master .. image:: https://travis-ci.org/hamcrest/PyHamcrest.png?branch=master
:alt: Build Status :alt: Build Status
:target: https://travis-ci.org/hamcrest/PyHamcrest :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 Introduction
============ ============
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
@@ -0,0 +1 @@
six>=1.4
9 changes: 5 additions & 4 deletions setup.py
Expand Up @@ -27,8 +27,8 @@ def read(fname):
fh.close() fh.close()


extra_attributes = {} extra_attributes = {}
if sys.version_info >= (3,): # if sys.version_info >= (3,):
extra_attributes['use_2to3'] = True # extra_attributes['use_2to3'] = True


params = dict( params = dict(
name='PyHamcrest', name='PyHamcrest',
Expand All @@ -45,17 +45,18 @@ def read(fname):
package_dir = {'': 'src'}, package_dir = {'': 'src'},
provides=['hamcrest'], provides=['hamcrest'],
long_description=read('README.rst'), long_description=read('README.rst'),
install_requires=['setuptools'], install_requires=['setuptools', 'six'],
classifiers=[ classifiers=[
'Development Status :: 5 - Production/Stable', 'Development Status :: 5 - Production/Stable',
'Environment :: Console', 'Environment :: Console',
'Intended Audience :: Developers', 'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License', 'License :: OSI Approved :: BSD License',
'Natural Language :: English', 'Natural Language :: English',
'Operating System :: OS Independent', 'Operating System :: OS Independent',
'Programming Language :: Python :: 2.5', 'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.2', 'Programming Language :: Python :: 3.2',
'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.3',
'Topic :: Software Development', 'Topic :: Software Development',
Expand Down
5 changes: 3 additions & 2 deletions src/hamcrest/__init__.py
@@ -1,5 +1,6 @@
from core import * from __future__ import absolute_import
from library import * from hamcrest.core import *
from hamcrest.library import *


__version__ = "1.8.0" __version__ = "1.8.0"
__author__ = "Chris Rose" __author__ = "Chris Rose"
Expand Down
5 changes: 3 additions & 2 deletions src/hamcrest/core/__init__.py
@@ -1,5 +1,6 @@
from assert_that import assert_that from __future__ import absolute_import
from core import * from hamcrest.core.assert_that import assert_that
from hamcrest.core.core import *


__author__ = "Jon Reid" __author__ = "Jon Reid"
__copyright__ = "Copyright 2011 hamcrest.org" __copyright__ = "Copyright 2011 hamcrest.org"
Expand Down
5 changes: 3 additions & 2 deletions src/hamcrest/core/assert_that.py
@@ -1,5 +1,6 @@
from matcher import Matcher from __future__ import absolute_import
from string_description import StringDescription from hamcrest.core.matcher import Matcher
from hamcrest.core.string_description import StringDescription


__author__ = "Jon Reid" __author__ = "Jon Reid"
__copyright__ = "Copyright 2011 hamcrest.org" __copyright__ = "Copyright 2011 hamcrest.org"
Expand Down
21 changes: 12 additions & 9 deletions src/hamcrest/core/base_description.py
@@ -1,13 +1,14 @@
from description import Description from __future__ import absolute_import
from selfdescribingvalue import SelfDescribingValue
from helpers.hasmethod import hasmethod

import warnings

__author__ = "Jon Reid" __author__ = "Jon Reid"
__copyright__ = "Copyright 2011 hamcrest.org" __copyright__ = "Copyright 2011 hamcrest.org"
__license__ = "BSD, see License.txt" __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): class BaseDescription(Description):
"""Base class for all :py:class:`~hamcrest.core.description.Description` """Base class for all :py:class:`~hamcrest.core.description.Description`
Expand All @@ -22,10 +23,12 @@ def append_text(self, text):
def append_description_of(self, value): def append_description_of(self, value):
if hasmethod(value, 'describe_to'): if hasmethod(value, 'describe_to'):
value.describe_to(self) value.describe_to(self)
elif isinstance(value, str): elif six.PY3 and isinstance(value, six.text_type):
self.append_string_in_python_syntax(value)
elif isinstance(value, unicode):
self.append(repr(value)) 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: else:
description = str(value) description = str(value)
if description[:1] == '<' and description[-1:] == '>': if description[:1] == '<' and description[-1:] == '>':
Expand Down
5 changes: 3 additions & 2 deletions src/hamcrest/core/base_matcher.py
@@ -1,9 +1,10 @@
from __future__ import absolute_import
__author__ = "Jon Reid" __author__ = "Jon Reid"
__copyright__ = "Copyright 2011 hamcrest.org" __copyright__ = "Copyright 2011 hamcrest.org"
__license__ = "BSD, see License.txt" __license__ = "BSD, see License.txt"


from matcher import Matcher from hamcrest.core.matcher import Matcher
from string_description import tostring from hamcrest.core.string_description import tostring




class BaseMatcher(Matcher): class BaseMatcher(Matcher):
Expand Down
23 changes: 12 additions & 11 deletions src/hamcrest/core/core/__init__.py
@@ -1,16 +1,17 @@
from __future__ import absolute_import
"""Fundamental matchers of objects and values, and composite matchers.""" """Fundamental matchers of objects and values, and composite matchers."""


from allof import all_of from hamcrest.core.core.allof import all_of
from anyof import any_of from hamcrest.core.core.anyof import any_of
from described_as import described_as from hamcrest.core.core.described_as import described_as
from is_ import is_ from hamcrest.core.core.is_ import is_
from isanything import anything from hamcrest.core.core.isanything import anything
from isequal import equal_to from hamcrest.core.core.isequal import equal_to
from isinstanceof import instance_of from hamcrest.core.core.isinstanceof import instance_of
from isnone import none, not_none from hamcrest.core.core.isnone import none, not_none
from isnot import is_not from hamcrest.core.core.isnot import is_not
from issame import same_instance from hamcrest.core.core.issame import same_instance
from raises import calling, raises from hamcrest.core.core.raises import calling, raises


__author__ = "Jon Reid" __author__ = "Jon Reid"
__copyright__ = "Copyright 2011 hamcrest.org" __copyright__ = "Copyright 2011 hamcrest.org"
Expand Down
3 changes: 2 additions & 1 deletion src/hamcrest/core/core/is_.py
@@ -1,10 +1,11 @@
from __future__ import absolute_import
__author__ = "Jon Reid" __author__ = "Jon Reid"
__copyright__ = "Copyright 2011 hamcrest.org" __copyright__ = "Copyright 2011 hamcrest.org"
__license__ = "BSD, see License.txt" __license__ = "BSD, see License.txt"


from hamcrest.core.base_matcher import BaseMatcher from hamcrest.core.base_matcher import BaseMatcher
from hamcrest.core.helpers.wrap_matcher import wrap_matcher, is_matchable_type 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): class Is(BaseMatcher):
Expand Down
3 changes: 2 additions & 1 deletion src/hamcrest/core/core/isnone.py
@@ -1,9 +1,10 @@
from __future__ import absolute_import
__author__ = "Jon Reid" __author__ = "Jon Reid"
__copyright__ = "Copyright 2011 hamcrest.org" __copyright__ = "Copyright 2011 hamcrest.org"
__license__ = "BSD, see License.txt" __license__ = "BSD, see License.txt"


from hamcrest.core.base_matcher import BaseMatcher from hamcrest.core.base_matcher import BaseMatcher
from isnot import is_not from .isnot import is_not




class IsNone(BaseMatcher): class IsNone(BaseMatcher):
Expand Down
5 changes: 3 additions & 2 deletions src/hamcrest/core/core/isnot.py
@@ -1,11 +1,12 @@
from __future__ import absolute_import
__author__ = "Jon Reid" __author__ = "Jon Reid"
__copyright__ = "Copyright 2011 hamcrest.org" __copyright__ = "Copyright 2011 hamcrest.org"
__license__ = "BSD, see License.txt" __license__ = "BSD, see License.txt"


from hamcrest.core.base_matcher import BaseMatcher, Matcher from hamcrest.core.base_matcher import BaseMatcher, Matcher
from hamcrest.core.helpers.wrap_matcher import wrap_matcher, is_matchable_type from hamcrest.core.helpers.wrap_matcher import wrap_matcher, is_matchable_type
from isequal import equal_to from .isequal import equal_to
from isinstanceof import instance_of from .isinstanceof import instance_of




class IsNot(BaseMatcher): class IsNot(BaseMatcher):
Expand Down
4 changes: 3 additions & 1 deletion src/hamcrest/core/helpers/wrap_matcher.py
@@ -1,3 +1,5 @@
import six

from hamcrest.core.base_matcher import Matcher from hamcrest.core.base_matcher import Matcher
from hamcrest.core.core.isequal import equal_to from hamcrest.core.core.isequal import equal_to


Expand All @@ -23,7 +25,7 @@ def is_matchable_type(expected_type):
if isinstance(expected_type, type): if isinstance(expected_type, type):
return True return True


if type(expected_type) == types.ClassType: if isinstance(expected_type, six.class_types):
return True return True


return False return False
3 changes: 2 additions & 1 deletion src/hamcrest/core/matcher.py
@@ -1,4 +1,5 @@
from selfdescribing import SelfDescribing from __future__ import absolute_import
from .selfdescribing import SelfDescribing


__author__ = "Jon Reid" __author__ = "Jon Reid"
__copyright__ = "Copyright 2011 hamcrest.org" __copyright__ = "Copyright 2011 hamcrest.org"
Expand Down
3 changes: 2 additions & 1 deletion src/hamcrest/core/string_description.py
@@ -1,4 +1,5 @@
from base_description import BaseDescription from __future__ import absolute_import
from .base_description import BaseDescription


__author__ = "Jon Reid" __author__ = "Jon Reid"
__copyright__ = "Copyright 2011 hamcrest.org" __copyright__ = "Copyright 2011 hamcrest.org"
Expand Down
11 changes: 6 additions & 5 deletions src/hamcrest/library/__init__.py
@@ -1,11 +1,12 @@
from __future__ import absolute_import
"""Library of Matcher implementations.""" """Library of Matcher implementations."""


from hamcrest.core import * from hamcrest.core import *
from collection import * from hamcrest.library.collection import *
from integration import * from hamcrest.library.integration import *
from number import * from hamcrest.library.number import *
from object import * from hamcrest.library.object import *
from text import * from hamcrest.library.text import *


__author__ = "Jon Reid" __author__ = "Jon Reid"
__copyright__ = "Copyright 2011 hamcrest.org" __copyright__ = "Copyright 2011 hamcrest.org"
Expand Down
Expand Up @@ -52,4 +52,4 @@ def only_contains(*items):
matchers = [] matchers = []
for item in items: for item in items:
matchers.append(wrap_matcher(item)) matchers.append(wrap_matcher(item))
return IsSequenceOnlyContaining(apply(any_of, matchers)) return IsSequenceOnlyContaining(any_of(*matchers))
3 changes: 2 additions & 1 deletion src/hamcrest/library/integration/__init__.py
@@ -1,6 +1,7 @@
from __future__ import absolute_import
"""Utilities for integrating Hamcrest with other libraries.""" """Utilities for integrating Hamcrest with other libraries."""


from match_equality import match_equality from .match_equality import match_equality


__author__ = "Jon Reid" __author__ = "Jon Reid"
__copyright__ = "Copyright 2011 hamcrest.org" __copyright__ = "Copyright 2011 hamcrest.org"
Expand Down
5 changes: 3 additions & 2 deletions src/hamcrest/library/number/__init__.py
@@ -1,7 +1,8 @@
from __future__ import absolute_import
"""Matchers that perform numeric comparisons.""" """Matchers that perform numeric comparisons."""


from iscloseto import close_to from .iscloseto import close_to
from ordering_comparison import greater_than, greater_than_or_equal_to, less_than, less_than_or_equal_to from .ordering_comparison import greater_than, greater_than_or_equal_to, less_than, less_than_or_equal_to


__author__ = "Jon Reid" __author__ = "Jon Reid"
__copyright__ = "Copyright 2011 hamcrest.org" __copyright__ = "Copyright 2011 hamcrest.org"
Expand Down
3 changes: 2 additions & 1 deletion src/hamcrest/library/number/iscloseto.py
@@ -1,3 +1,4 @@
import six
from hamcrest.core.base_matcher import BaseMatcher from hamcrest.core.base_matcher import BaseMatcher
from math import fabs from math import fabs


Expand All @@ -9,7 +10,7 @@
def isnumeric(value): def isnumeric(value):
"""Confirm that 'value' can be treated numerically; duck-test accordingly """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 return True


try: try:
Expand Down
7 changes: 4 additions & 3 deletions src/hamcrest/library/object/__init__.py
@@ -1,8 +1,9 @@
from __future__ import absolute_import
"""Matchers that inspect objects and classes.""" """Matchers that inspect objects and classes."""


from haslength import has_length from .haslength import has_length
from hasproperty import has_property, has_properties from .hasproperty import has_property, has_properties
from hasstring import has_string from .hasstring import has_string


__author__ = "Jon Reid" __author__ = "Jon Reid"
__copyright__ = "Copyright 2011 hamcrest.org" __copyright__ = "Copyright 2011 hamcrest.org"
Expand Down
15 changes: 8 additions & 7 deletions src/hamcrest/library/text/__init__.py
@@ -1,12 +1,13 @@
from __future__ import absolute_import
"""Matchers that perform text comparisons.""" """Matchers that perform text comparisons."""


from isequal_ignoring_case import equal_to_ignoring_case from .isequal_ignoring_case import equal_to_ignoring_case
from isequal_ignoring_whitespace import equal_to_ignoring_whitespace from .isequal_ignoring_whitespace import equal_to_ignoring_whitespace
from stringcontains import contains_string from .stringcontains import contains_string
from stringendswith import ends_with from .stringendswith import ends_with
from stringstartswith import starts_with from .stringstartswith import starts_with
from stringmatches import matches_regexp from .stringmatches import matches_regexp
from stringcontainsinorder import string_contains_in_order from .stringcontainsinorder import string_contains_in_order


__author__ = "Jon Reid" __author__ = "Jon Reid"
__copyright__ = "Copyright 2011 hamcrest.org" __copyright__ = "Copyright 2011 hamcrest.org"
Expand Down

0 comments on commit aa4e6cd

Please sign in to comment.