File: test_formatting.py

package info (click to toggle)
pint-xarray 0.6.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,244 kB
  • sloc: python: 5,043; makefile: 4
file content (23 lines) | stat: -rw-r--r-- 553 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import pint
import pytest

# only need to register _repr_inline_
import pint_xarray  # noqa: F401

unit_registry = pint.UnitRegistry(force_ndarray_like=True)


@pytest.mark.parametrize(
    ("length", "expected"),
    (
        (40, "[N] 7.1 5.4 9.8 21.4 15.3"),
        (20, "[N] 7.1 5.4 ... 15.3"),
        (10, "[N] 7.1..."),
        (7, "[N] ..."),
        (3, "[N] ..."),
    ),
)
def test_inline_repr(length, expected):
    quantity = unit_registry.Quantity([7.1, 5.4, 9.8, 21.4, 15.3], "N")

    assert quantity._repr_inline_(length) == expected