Skip to content

Commit

Permalink
Unit tests can now be run with core dependencies only (param and numpy)
Browse files Browse the repository at this point in the history
  • Loading branch information
jlstevens committed Mar 26, 2015
1 parent 54eb701 commit 18ee923
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 20 deletions.
9 changes: 6 additions & 3 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import os, sys

# Standardize backend due to random inconsistencies
from matplotlib import pyplot
pyplot.switch_backend('agg')
try:
# Standardize backend due to random inconsistencies
from matplotlib import pyplot
pyplot.switch_backend('agg')
except:
pass

cwd = os.path.abspath(os.path.split(__file__)[0])
sys.path.insert(0, os.path.join(cwd, '..'))
10 changes: 7 additions & 3 deletions tests/testmagics.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
from holoviews.core.options import Store
from unittest import SkipTest

from holoviews import ipython
from holoviews.ipython import IPTestCase
from holoviews.core.options import Store
try:
from holoviews import ipython
from holoviews.ipython import IPTestCase
except ImportError:
raise SkipTest("Required dependencies not satisfied for testing magics")

from holoviews.operation import Compositor

Expand Down
13 changes: 9 additions & 4 deletions tests/testoptscompleter.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
"""
Tests the OptCompleter class for tab-completion in the opts magic.
Tests the OptsCompleter class for tab-completion in the opts magic.
"""
from holoviews import ipython
from holoviews.ipython import IPTestCase
from holoviews.ipython.magics import OptsCompleter

from unittest import SkipTest
try:
from holoviews import ipython
from holoviews.ipython import IPTestCase
from holoviews.ipython.magics import OptsCompleter
except ImportError:
raise SkipTest("Required dependencies not satisfied for testing OptsCompleter")


class TestOptsCompleter(IPTestCase):
Expand Down
14 changes: 10 additions & 4 deletions tests/testrenderclass.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from hashlib import sha256
from unittest import SkipTest
import numpy as np

from holoviews import HoloMap, Store
Expand All @@ -7,10 +8,12 @@

from nose.plugins.attrib import attr

# Standardize backend due to random inconsistencies
from matplotlib import pyplot
pyplot.switch_backend('agg')

try:
# Standardize backend due to random inconsistencies
from matplotlib import pyplot
pyplot.switch_backend('agg')
except:
pyplot = None

def digest_data(data):
hashfn = sha256()
Expand All @@ -26,6 +29,9 @@ class MPLPlotRendererTest(ComparisonTestCase):
"""

def setUp(self):
if pyplot is None:
raise SkipTest("Matplotlib required to test widgets")

self.basename = 'no-file'
self.image1 = Image(np.array([[0,1],[2,3]]), label='Image1')
self.image2 = Image(np.array([[1,0],[4,-2]]), label='Image2')
Expand Down
15 changes: 9 additions & 6 deletions tests/testwidgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
"""
import re
from hashlib import sha256
from unittest import SkipTest
import numpy as np

from holoviews.ipython import IPTestCase
from holoviews.ipython.widgets import ScrubberWidget, SelectionWidget

# Standardize backend due to random inconsistencies
from matplotlib import pyplot
pyplot.switch_backend('agg')
try:
from holoviews.ipython import IPTestCase
from holoviews.ipython.widgets import ScrubberWidget, SelectionWidget
# Standardize backend due to random inconsistencies
from matplotlib import pyplot
pyplot.switch_backend('agg')
except:
raise SkipTest("Matplotlib required to test widgets")

from holoviews import Image, HoloMap
from holoviews.plotting import RasterPlot
Expand Down

0 comments on commit 18ee923

Please sign in to comment.