Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Remove dependency on nose package #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ os:
env:
global:
- SETUP_XVFB=True
- CONDA_DEPENDENCIES="pytest matplotlib nose coverage"
- CONDA_DEPENDENCIES="pytest matplotlib coverage"
- PIP_DEPENDENCIES="pytest-cov coveralls"
matrix:
- PYTHON_VERSION=2.6 MATPLOTLIB_VERSION=1.4 NUMPY_VERSION=1.9
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ For more information on how to write tests to do this, see the **Using** section
Installing
----------

This plugin is compatible with Python 2.6, 2.7, and 3.3 and later, and requires [pytest](http://pytest.org), [matplotlib](http://www.matplotlib.org) and
[nose](http://nose.readthedocs.org/) to be installed (nose is required by Matplotlib).
This plugin is compatible with Python 2.6, 2.7, and 3.3 and later, and requires
[pytest](http://pytest.org) and [matplotlib](http://www.matplotlib.org) to be
installed.

To install, you can do:

Expand Down
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ environment:
PYTHON_ARCH: "64" # needs to be set for CMD_IN_ENV to succeed. If a mix
# of 32 bit and 64 bit builds are needed, move this
# to the matrix section.
CONDA_DEPENDENCIES: "pytest matplotlib nose"
CONDA_DEPENDENCIES: "pytest matplotlib"

matrix:
- PYTHON_VERSION: "2.6"
Expand All @@ -33,5 +33,5 @@ build: false

test_script:
- "%CMD_IN_ENV% cd tests"
- "%CMD_IN_ENV% python -c 'import pytest_mpl.plugin'"
- "%CMD_IN_ENV% py.test --mpl -v"

35 changes: 32 additions & 3 deletions pytest_mpl/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,38 @@

import matplotlib
import matplotlib.pyplot as plt
from matplotlib.testing.compare import compare_images
from matplotlib.testing.decorators import ImageComparisonTest as MplImageComparisonTest
from matplotlib.testing.decorators import cleanup

# The following imports in Matplotlib may require nose even though the
# functionality we import doesn't require it. Therefore, if nose isn't
# installed, we mock the module temporarily to avoid requiring it as a
# dependency. We could in principle use the mock module but that would
# then add a dependency.

try:
import nose
except ImportError:
NOSE_INSTALLED = False
else:
NOSE_INSTALLED = True

try:

if not NOSE_INSTALLED:
import imp
sys.modules['nose'] = imp.new_module('nose')
sys.modules['nose.plugins.errorclass'] = imp.new_module('nose.plugins.errorclass')

from matplotlib.testing.compare import compare_images
from matplotlib.testing.decorators import ImageComparisonTest as MplImageComparisonTest
from matplotlib.testing.decorators import cleanup

finally:

if not NOSE_INSTALLED:
sys.modules.pop('nose')
sys.modules.pop('nose.plugins.errorclass')

# We don't use six in the following to avoid adding a dependency

if sys.version_info[0] == 2:
from urllib import urlopen
Expand Down