Skip to content

Commit

Permalink
Merge 52d25e8 into f676aae
Browse files Browse the repository at this point in the history
  • Loading branch information
emcconville committed Nov 6, 2018
2 parents f676aae + 52d25e8 commit cda8ae1
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 30 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -9,3 +9,5 @@ dist
.cache
.coverage
.DS_Store
.pytest_cache

22 changes: 7 additions & 15 deletions .travis.yml
@@ -1,35 +1,27 @@
language: python
sudo: false
python:
- 2.6
- 2.7
- 3.2
- 3.3
- 3.4
- 3.5
- 3.6
- pypy
- pypy3
env:
- secure: "EhG2uSD2m1eGxuL2HeQewJJx7MVL4WpjrxyfiUBEgsApemD1yKJPjUnLwAyd\nbPi5HJx5ySm1TTRSvj6/yP85YLYTaJHA8OabKk7p0wFW294qcrYIDGovU7NL\n3YOqZmqN+S3XOBGFCOnByxE+pcxxWW/3/I09EgeW7D6tBPh67G0="
install:
- echo $TRAVIS_PYTHON_VERSION
- pip install pytest pytest-xdist pytest-capturelog memory_profiler==0.40 psutil coveralls flake8
- pip install pytest pytest-xdist memory_profiler==0.40 psutil coveralls
- >
if [[ "$TRAVIS_PYTHON_VERSION" != "3.2" && "$TRAVIS_PYTHON_VERSION" != "pypy" && "$TRAVIS_PYTHON_VERSION" != "pypy3" ]]; then
if [[ "$TRAVIS_PYTHON_VERSION" != "pypy" && "$TRAVIS_PYTHON_VERSION" != "pypy3" ]]; then
pip install 'pytest-cov>=1.8.0';
fi
- pip install -e .
script:
- python -mwand.version --verbose
- >
if [[ "$TRAVIS_PYTHON_VERSION" == "3.2" || "$TRAVIS_PYTHON_VERSION" == "pypy" || "$TRAVIS_PYTHON_VERSION" == "pypy3" ]]; then
py.test --boxed --durations=20;
if [[ "$TRAVIS_PYTHON_VERSION" == "pypy" || "$TRAVIS_PYTHON_VERSION" == "pypy3" ]]; then
py.test --no-pdf --boxed --durations=20;
else
py.test --cov wand --boxed --durations=20;
fi
- >
if [[ "$TRAVIS_PYTHON_VERSION" != "2.6" ]]; then
flake8 .;
py.test --no-pdf --cov wand --boxed --durations=20;
fi
after_success:
- coveralls
- coveralls
2 changes: 1 addition & 1 deletion docs/conf.py
Expand Up @@ -268,7 +268,7 @@ def __repr__(self):
# fall back if theme is not there
try:
__import__('flask_theme_support')
except ImportError as e:
except ImportError:
print('-' * 74)
print('Warning: Flask themes unavailable. Building with default theme')
print('If you want the Flask themes, run this command and build again:')
Expand Down
7 changes: 4 additions & 3 deletions tests/color_test.py
@@ -1,4 +1,4 @@
import platform
import ctypes
import time

from memory_profiler import memory_usage
Expand Down Expand Up @@ -110,7 +110,8 @@ def color_memory_leak():
@mark.skipif('MAGICK_VERSION_INFO <= (6, 6, 9, 7)')
def test_memory_leak():
"""https://github.com/emcconville/wand/pull/127"""
minimum = 1.0
with Color('NONE') as nil_color:
minimum = ctypes.sizeof(nil_color.raw)
consumes = memory_usage((color_memory_leak, (), {}))
vm = platform.python_implementation()
minimum = 15.0 if vm == 'PyPy' else 1.0 # FIXME
assert consumes[-1] - consumes[0] <= minimum
3 changes: 3 additions & 0 deletions tests/conftest.py
Expand Up @@ -23,6 +23,9 @@ def pytest_addoption(parser):
'display() fixture if present. Useful for '
'debugging on CI',
default=os.environ.get('IMGUR_CLIENT_ID'))
parser.addoption('--no-pdf', action='store_true', dest='nopdf',
help='Skip any test with PDF documents.',
default=False)


def pytest_runtest_setup(item):
Expand Down
17 changes: 11 additions & 6 deletions tests/drawing_test.py
Expand Up @@ -7,7 +7,7 @@
from wand.compat import nested, text
from wand.api import library
from wand.drawing import Drawing
from wand.exceptions import WandLibraryVersionError
from wand.exceptions import PolicyError, WandLibraryVersionError


@fixture
Expand Down Expand Up @@ -223,11 +223,16 @@ def test_draw_circle(fx_asset):
def test_draw_comment():
comment = 'pikachu\'s ghost'
expected = '#pikachu\'s ghost\n'
with nested(Image(width=1, height=1), Drawing()) as (img, draw):
draw.comment(comment)
draw(img)
blob = img.make_blob(format="mvg")
assert expected == text(blob)
with Image(width=1, height=1) as img:
with Drawing() as draw:
draw.comment(comment)
draw(img)
try:
blob = img.make_blob(format="mvg")
except PolicyError as pe:
skip("MVG disabled by security polcies.")
else:
assert expected == text(blob)


def test_draw_color():
Expand Down
8 changes: 6 additions & 2 deletions tests/image_test.py
Expand Up @@ -9,12 +9,12 @@
import tempfile
import warnings

from pytest import mark, raises
from pytest import config, mark, raises

from wand.image import ClosedImageError, Image, IMAGE_LAYER_METHOD
from wand.color import Color
from wand.compat import PY3, string_type, text, text_type
from wand.exceptions import OptionError, MissingDelegateError
from wand.exceptions import MissingDelegateError, OptionError
from wand.font import Font

try:
Expand Down Expand Up @@ -321,13 +321,17 @@ def test_set_resolution_02(fx_asset):
assert img.resolution == (100, 100)


@mark.skipif(config.option.nopdf,
reason='Skipping any PDF document tests.')
def test_set_resolution_03(fx_asset):
"""Sets image resolution on constructor"""
with Image(filename=str(fx_asset.join('sample.pdf')),
resolution=(100, 100)) as img:
assert img.resolution == (100, 100)


@mark.skipif(config.option.nopdf,
reason='Skipping any PDF document tests.')
def test_set_resolution_04(fx_asset):
"""Sets image resolution on constructor with integer as parameter."""
with Image(filename=str(fx_asset.join('sample.pdf')),
Expand Down
2 changes: 1 addition & 1 deletion tests/misc_test.py
Expand Up @@ -11,7 +11,7 @@

def test_version():
"""Test version strings."""
match = re.match('^ImageMagick\s+\d+\.\d+\.\d+(?:-\d+)?', MAGICK_VERSION)
match = re.match(r'^ImageMagick\s+\d+\.\d+\.\d+(?:-\d+)?', MAGICK_VERSION)
assert match
assert isinstance(MAGICK_VERSION_INFO, tuple)
assert (len(MAGICK_VERSION_INFO) ==
Expand Down
2 changes: 1 addition & 1 deletion wand/font.py
Expand Up @@ -5,7 +5,7 @@
:class:`Font` is an object which takes the :attr:`~Font.path` of font file,
:attr:`~Font.size`, :attr:`~Font.color`, and whether to use
:attr:`~Font.antialias`\ ing. If you want to use font by its name rather
:attr:`~Font.antialias`\\ ing. If you want to use font by its name rather
than the file path, use TTFQuery_ package. The font path resolution by its
name is a very complicated problem to achieve.
Expand Down
2 changes: 1 addition & 1 deletion wand/sequence.py
Expand Up @@ -269,7 +269,7 @@ class SingleImage(BaseImage):
Note that all changes on single images are invisible to their
containers until they are :meth:`~wand.image.BaseImage.close`\ d
(:meth:`~wand.resource.Resource.destroy`\ ed).
(:meth:`~wand.resource.Resource.destroy`\\ ed).
.. versionadded:: 0.3.0
Expand Down

0 comments on commit cda8ae1

Please sign in to comment.