Skip to content

Commit

Permalink
Merge branch 'release-1.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
offbyone committed Mar 8, 2015
2 parents 1f327f4 + 59e2813 commit 579f702
Show file tree
Hide file tree
Showing 10 changed files with 132 additions and 89 deletions.
36 changes: 11 additions & 25 deletions .travis.yml
@@ -1,40 +1,26 @@
language: python

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

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

matrix:
exclude:
- python: pypy
env: NUMPY="true"
- TOX_ENV=py33
- TOX_ENV=py33-numpy
- TOX_ENV=py32
- TOX_ENV=py27
- TOX_ENV=py27-numpy
- TOX_ENV=py26
- TOX_ENV=pypy
- TOX_ENV=docs-py3

before_install:
- export PYTHON_EXE=python
- export EASY_SETUP_URL='http://peak.telecommunity.com/dist/ez_setup.py'

install:
- 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 == "3.3" ]]; then export PYTHONHASHSEED=4; fi
- if [[ $TRAVIS_PYTHON_VERSION == "3.4" ]]; then export PYTHONHASHSEED=8; fi
- pip install --use-mirrors tox coveralls

script:
- $PYTHON_EXE setup.py develop
- py.test -v --cov hamcrest
- tox -e $TOX_ENV

after_success:
- coveralls
- coveralls
15 changes: 8 additions & 7 deletions doc/conf.py
Expand Up @@ -12,6 +12,7 @@
# serve to show the default.

import sys, os
import six

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
Expand Down Expand Up @@ -45,8 +46,8 @@
master_doc = 'index'

# General information about the project.
project = u'PyHamcrest'
copyright = u'2011, hamcrest.org'
project = six.u('PyHamcrest')
copyright = six.u('2011, hamcrest.org')

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -125,7 +126,7 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = []

# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
Expand Down Expand Up @@ -183,8 +184,8 @@
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'PyHamcrest.tex', u'PyHamcrest Documentation',
u'hamcrest.org', 'manual'),
('index', 'PyHamcrest.tex', six.u('PyHamcrest Documentation'),
six.u('hamcrest.org'), 'manual'),
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down Expand Up @@ -224,6 +225,6 @@ def setup(app):
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'pyhamcrest', u'PyHamcrest Documentation',
[u'hamcrest.org'], 1)
('index', 'pyhamcrest', six.u('PyHamcrest Documentation'),
[six.u('hamcrest.org')], 1)
]
49 changes: 49 additions & 0 deletions docker/Dockerfile
@@ -0,0 +1,49 @@
FROM ubuntu:14.04
MAINTAINER Chris Rose <offline@offby1.net>

# ensure the base image has what we need
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get -yqq install \
build-essential python-pip \
software-properties-common openjdk-7-jdk && \
add-apt-repository ppa:fkrull/deadsnakes && \
apt-get update

# install legacy python versions
RUN DEBIAN_FRONTEND=noninteractive apt-get -yqq install \
python2.5 python2.6 python2.7 python3.1 python3.2 python3.3 python3.4

# add Jython installer
# ADD jython-installer-2.7-b4.jar /tmp/
ADD http://search.maven.org/remotecontent?filepath=org/python/jython-installer/2.7-b4/jython-installer-2.7-b4.jar /tmp/jython-installer-2.7-b4.jar

# install pypy versions
# ADD pypy-2.5.0-linux64.tar.bz2 /opt/
# ADD pypy3-2.4.0-linux64.tar.bz2 /opt/
RUN mkdir -p /opt
ADD https://bitbucket.org/pypy/pypy/downloads/pypy3-2.4.0-linux64.tar.bz2 /tmp/
RUN cd /opt && tar -xf /tmp/pypy3-2.4.0-linux64.tar.bz2
ADD https://bitbucket.org/pypy/pypy/downloads/pypy-2.5.0-linux64.tar.bz2 /tmp/
RUN cd /opt && tar -xf /tmp/pypy-2.5.0-linux64.tar.bz2

# install Jython version
RUN java -jar /tmp/jython-installer-2.7-b4.jar -d /opt/jython-2.7-b4 -s -t all
ENV PATH /opt/jython-2.7-b4/bin:$PATH
# bootstrap jython JAR cache
RUN jython

# make PyPy available
ENV PATH /opt/pypy-2.5.0-linux64/bin:/opt/pypy3-2.4.0-linux64/bin:$PATH

ENV PYTHON_BUILD_DOCKER=true

# install tox
RUN pip install tox

ADD clean-launch.sh /tools/clean-launch.sh

VOLUME /src
WORKDIR /src

ENTRYPOINT ["/tools/clean-launch.sh"]
CMD ["tox"]
23 changes: 23 additions & 0 deletions docker/README.md
@@ -0,0 +1,23 @@
# Test hamcrest with Docker

## Simple testing steps

(this assumes that you have [Docker](https://docker.com) installed)

1. cd to the directory containing PyHamcrest's `tox.ini` file.
2. run `docker run --rm -v $(pwd):/src chrisr/pybuilder:latest`

That's it!

This will test PyHamcrest with all supported versions of Python

## Tweaking the build image

1. in this directory, modify the `Dockerfile` to have the setup you want
2. `docker build --tag $USER/pybuilder:latest .`
3. run your build
4. submit a pull request to the `hamcrest/PyHamcrest` repo with your
changes to the Dockerfile

We'll merge and publish the new tag to `chrisr/pybuilder:latest`,
making the new instructions up to date.
3 changes: 3 additions & 0 deletions docker/clean-launch.sh
@@ -0,0 +1,3 @@
#!/bin/bash
find /src \( -name __pycache__ -o -name '*.pyc' \) -delete
exec "$@"
2 changes: 2 additions & 0 deletions pytest.ini
@@ -0,0 +1,2 @@
[pytest]
addopts = --cov hamcrest --cov-report term-missing
5 changes: 5 additions & 0 deletions setup.py
Expand Up @@ -2,6 +2,11 @@
import os
import re

# need to kill off link if we're in docker builds
if os.environ.get('PYTHON_BUILD_DOCKER', None) == 'true':
del os.link


try:
from setuptools import setup, find_packages
except ImportError:
Expand Down
13 changes: 6 additions & 7 deletions src/hamcrest/library/collection/isdict_containingentries.py
Expand Up @@ -10,7 +10,7 @@
class IsDictContainingEntries(BaseMatcher):

def __init__(self, value_matchers):
self.value_matchers = value_matchers
self.value_matchers = sorted(value_matchers.items())

def _not_a_dictionary(self, dictionary, mismatch_description):
if mismatch_description:
Expand All @@ -19,7 +19,7 @@ def _not_a_dictionary(self, dictionary, mismatch_description):
return False

def matches(self, dictionary, mismatch_description=None):
for key in self.value_matchers:
for key, value_matcher in self.value_matchers:

try:
if not key in dictionary:
Expand All @@ -32,7 +32,6 @@ def matches(self, dictionary, mismatch_description=None):
except TypeError:
return self._not_a_dictionary(dictionary, mismatch_description)

value_matcher = self.value_matchers[key]
try:
actual_value = dictionary[key]
except TypeError:
Expand All @@ -51,19 +50,19 @@ def matches(self, dictionary, mismatch_description=None):
def describe_mismatch(self, item, mismatch_description):
self.matches(item, mismatch_description)

def describe_keyvalue(self, index, description):
def describe_keyvalue(self, index, value, description):
"""Describes key-value pair at given index."""
description.append_description_of(index) \
.append_text(': ') \
.append_description_of(self.value_matchers[index])
.append_description_of(value)

def describe_to(self, description):
description.append_text('a dictionary containing {')
first = True
for key in self.value_matchers:
for key, value in self.value_matchers:
if not first:
description.append_text(', ')
self.describe_keyvalue(key, description)
self.describe_keyvalue(key, value, description)
first = False
description.append_text('}')

Expand Down
Expand Up @@ -97,7 +97,6 @@ def testProvidesConvenientShortcutForMatchingWithEqualTo(self):
self.assert_matches('has c & a', has_entries('c', 3, 'a', 1), target)
self.assert_does_not_match('no d:4', has_entries('b', 3, 'd', 4), target)

@unittest.skipIf('java' in platform.system().lower(), "Hash randomization makes this unpredictably fail")
def testHasReadableDescription(self):
self.assert_description("a dictionary containing {'a': <1>, 'b': <2>}",
has_entries('a', 1, 'b', 2))
Expand All @@ -115,10 +114,10 @@ def testMismatchDescriptionOfDictionaryWithNonMatchingValue(self):
def testDescribeMismatchOfNonDictionaryShowsActualArgument(self):
self.assert_describe_mismatch("'bad' is not a mapping object", has_entries('a', 1), 'bad')

@unittest.skipIf('java' in platform.system().lower(), "Hash randomization makes this unpredictably fail")
def testDescribeMismatchOfDictionaryWithoutKey(self):
self.assert_describe_mismatch("no 'b' key in <{'a': 1, 'c': 3}>",
has_entries('a', 1, 'b', 2), {'a': 1, 'c': 3})
d = {'a': 1, 'c': 3}
self.assert_describe_mismatch("no 'b' key in <%s>" % (d, ),
has_entries('a', 1, 'b', 2), d)

def testDescribeMismatchOfDictionaryWithNonMatchingValue(self):
self.assert_describe_mismatch("value for 'a' was <2>",
Expand Down
68 changes: 22 additions & 46 deletions tox.ini
@@ -1,5 +1,5 @@
[tox]
envlist = py26,py27,py32,py33,py34,pypy
envlist = py26,py27,py32,py33,py34,pypy,docs-py3
# envlist = py26,py27,py27-numpy,py32,py33,py33-numpy,pypy
# Jython is not testable, but there's no reason it should not work.
# py25 and py31 are deprecated as of 1.7.2
Expand All @@ -8,69 +8,45 @@ envlist = py26,py27,py32,py33,py34,pypy
commands = {envbindir}/py.test []
{envpython} tests/object_import.py
deps = pytest
unittest2
pytest-cov

[testenv:py25]
[testenv:py26]
setenv = PIP_INSECURE=1
commands = {envbindir}/py.test []
deps = pytest
six
deps = {[testenv]deps}
unittest2

[testenv:py31] # deprecated as of 1.7.2
commands = {envbindir}/py.test []
{envpython} tests/object_import.py
deps = pytest

[testenv:py32]
commands = {envbindir}/py.test []
{envpython} tests/object_import.py
deps = pytest

[testenv:py33]
commands = {envbindir}/py.test []
{envpython} tests/object_import.py
deps = pytest
setenv =
PYTHONHASHSEED = 1

[testenv:py34]
commands = {envbindir}/py.test []
{envpython} tests/object_import.py
deps = pytest
setenv =
PYTHONHASHSEED = 5

[testenv:pypy]
commands = {envbindir}/py.test []
{envbindir}/pypy tests/object_import.py

[testenv:jython]
deps = pytest
commands = {envbindir}/jython tests/alltests.py []
{envpython} tests/object_import.py

[testenv:py27-numpy]
commands = {envbindir}/py.test []
{envpython} tests/object_import.py
deps = pytest
unittest2
basepython = python2.7
deps = {[testenv]deps}
numpy

[testenv:py33-numpy]
basepython = python3.3
commands = {envbindir}/py.test []
{envpython} tests/object_import.py
deps = pytest
deps = {[testenv]deps}
numpy
setenv =
PYTHONHASHSEED = 1
PYTHONHASHSEED = 4


[testenv:py34-numpy]
basepython = python3.4
commands = {envbindir}/py.test []
{envpython} tests/object_import.py
deps = pytest
deps = {[testenv]deps}
numpy
setenv =
PYTHONHASHSEED = 5

[testenv:docs-py3]
basepython = python3.4
deps = sphinx
changedir = {toxinidir}/doc
commands = sphinx-build -W -b html -d {envtmpdir}/doctrees . {envtmpdir}/html

[testenv:docs-py2]
basepython = python2.7
deps = sphinx
changedir = {toxinidir}/doc
commands = sphinx-build -W -b html -d {envtmpdir}/doctrees . {envtmpdir}/html

0 comments on commit 579f702

Please sign in to comment.