From 2bd1bd9aedc40a1186dbde9103081c8c08366953 Mon Sep 17 00:00:00 2001 From: Colin Talbert Date: Tue, 7 Jun 2016 08:45:03 -0600 Subject: [PATCH] Refactored mpl.use('agg') from the tests __init__ replaced with a swap of plt.show with an empty lambda --- tests/__init__.py | 6 ------ tests/test_dataset_mask.py | 7 +++++++ tests/test_deprecations.py | 7 +++++++ tests/test_reshape_image.py | 6 ++++++ tests/test_tool.py | 3 +++ 5 files changed, 23 insertions(+), 6 deletions(-) diff --git a/tests/__init__.py b/tests/__init__.py index 909c3724..e69de29b 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,6 +0,0 @@ -# -try: - import matplotlib as mpl - mpl.use('agg') -except ImportError: - pass \ No newline at end of file diff --git a/tests/test_dataset_mask.py b/tests/test_dataset_mask.py index e4d24407..86d3254f 100644 --- a/tests/test_dataset_mask.py +++ b/tests/test_dataset_mask.py @@ -4,6 +4,13 @@ import sys import numpy as np import pytest +try: + import matplotlib as mpl + mpl.use('agg') + import matplotlib.pyplot as plt +except ImportError: + plt = None + from affine import Affine import rasterio from rasterio.enums import MaskFlags diff --git a/tests/test_deprecations.py b/tests/test_deprecations.py index 6f87545d..2bc247f8 100644 --- a/tests/test_deprecations.py +++ b/tests/test_deprecations.py @@ -15,6 +15,13 @@ from rasterio import ( get_data_window, window_intersection, window_union, windows_intersect ) +try: + import matplotlib as mpl + mpl.use('agg') + import matplotlib.pyplot as plt + plt.show = lambda :None +except: + pass DATA_WINDOW = ((3, 5), (2, 6)) diff --git a/tests/test_reshape_image.py b/tests/test_reshape_image.py index fa4e375b..8dcb4050 100644 --- a/tests/test_reshape_image.py +++ b/tests/test_reshape_image.py @@ -2,6 +2,12 @@ import numpy as np import rasterio +try: + import matplotlib as mpl + mpl.use('agg') +except: + pass + def test_reshape(): with rasterio.open('tests/data/RGB.byte.tif') as src: im_data = rasterio.plot.reshape_as_image(src.read()) diff --git a/tests/test_tool.py b/tests/test_tool.py index da5acdc7..d3fbf6f0 100644 --- a/tests/test_tool.py +++ b/tests/test_tool.py @@ -1,7 +1,10 @@ import numpy as np try: + import matplotlib as mpl + mpl.use('agg') import matplotlib.pyplot as plt + plt.show = lambda :None except ImportError: plt = None