Skip to content

Commit

Permalink
Add test for .metpy.units loading thru variable.data
Browse files Browse the repository at this point in the history
  • Loading branch information
dcamron committed Apr 26, 2021
1 parent 8e4015b commit adecf7e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/test_xarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# SPDX-License-Identifier: BSD-3-Clause
"""Test the operation of MetPy's XArray accessors."""
from collections import OrderedDict
from unittest.mock import patch, PropertyMock

import numpy as np
import pyproj
Expand Down Expand Up @@ -115,6 +116,13 @@ def test_units(test_var):
assert test_var.metpy.units == units.kelvin


def test_units_data(test_var):
"""Test units property fetching does not touch variable.data."""
with patch.object(xr.Variable, 'data', new_callable=PropertyMock) as mock_data_property:
test_var.metpy.units
mock_data_property.assert_not_called()


def test_units_percent():
"""Test that '%' is handled as 'percent'."""
test_var_percent = xr.open_dataset(
Expand Down

0 comments on commit adecf7e

Please sign in to comment.