Completed
Pull Request — master (#413)
by
unknown
01:20
created

test_add_logo_small()   A

Complexity

Conditions 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
1
# Copyright (c) 2008-2016 MetPy Developers.
2
# Distributed under the terms of the BSD 3-Clause License.
3
# SPDX-License-Identifier: BSD-3-Clause
4
"""Tests for the `_util` module."""
5
6
from datetime import datetime
7
8
import matplotlib
9
import matplotlib.pyplot as plt
10
import pytest
11
12
from metpy.plots import add_logo, add_timestamp
13
# Fixture to make sure we have the right backend
14
from metpy.testing import patch_round, set_agg_backend  # noqa: F401
15
16
MPL_VERSION = matplotlib.__version__[:3]
17
18
19
@pytest.mark.mpl_image_compare(tolerance={'1.4': 5.58}.get(MPL_VERSION, 0.), remove_text=True)
20
def test_add_timestamp():
21
    """Test adding a timestamp to an axes object."""
22
    fig = plt.figure(figsize=(9, 9))
23
    ax = plt.subplot(1, 1, 1)
24
    add_timestamp(ax, time=datetime(2017, 1, 1))
25
    return fig
26
27
28
@pytest.mark.mpl_image_compare(tolerance=0, remove_text=True)
29
def test_add_logo_small():
30
    """Test adding a logo to a figure."""
31
    fig = plt.figure(figsize=(9, 9))
32
    add_logo(fig)
33
    return fig
34
35
36
@pytest.mark.mpl_image_compare(tolerance=0, remove_text=True)
37
def test_add_logo_large():
38
    """Test adding a logo to a figure."""
39
    fig = plt.figure(figsize=(9, 9))
40
    add_logo(fig, size='large')
41
    return fig
42
43
44
def test_add_logo_invalid_size():
45
    """Test adding a logo to a figure with an invalid size specification."""
46
    fig = plt.figure(figsize=(9, 9))
47
    with pytest.raises(ValueError):
48
        add_logo(fig, size='jumbo')
49