aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2017-08-03 00:12:31 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2017-08-03 00:12:31 +0200
commit4c0acd35552f213effcea1df275242f3a4476ae3 (patch)
tree24a7ac60eb6f2a0cd2a57363159ea55333274b4a /test
parentc2d21a4c36cf9374b708f580af2fd420bb9b1146 (diff)
downloadee-python-4c0acd35552f213effcea1df275242f3a4476ae3.tar.gz
ee-python-4c0acd35552f213effcea1df275242f3a4476ae3.tar.bz2
ee-python-4c0acd35552f213effcea1df275242f3a4476ae3.tar.xz
ee-python-4c0acd35552f213effcea1df275242f3a4476ae3.zip
eng_str(): Adding unit argument.
Diffstat (limited to 'test')
-rw-r--r--test/test_formatting.py28
1 files changed, 24 insertions, 4 deletions
diff --git a/test/test_formatting.py b/test/test_formatting.py
index 560daee..6fa0b07 100644
--- a/test/test_formatting.py
+++ b/test/test_formatting.py
@@ -1,7 +1,9 @@
import pytest
+import numpy as np
from ee.formatting import eng_str
@pytest.mark.parametrize("input,expected", [
+ (0, "0"),
(5.5, "5.5"),
(55, "55"),
(550, "550"),
@@ -9,9 +11,27 @@ from ee.formatting import eng_str
(55000, "55 k"),
(550000, "550 k"),
(5500000, "5.5 M"),
- ])
+ (0.5, "500 m"),
+ (0.055, "55 m"),
+ (0.0055, "5.5 m"),
+ (0.00055, "550 u"),
+ (0.000055, "55 u"),
+ (0.0000055, "5.5 u"),
+ (0.00000055, "550 p"),
+ ])
def test_eng_str(input, expected):
- assert eng_str(input) == expected
+ assert expected == eng_str(input)
+ npinput = np.float64(input)
+ assert expected == eng_str(npinput)
+
+@pytest.mark.parametrize("input,expected", [
+ (0, "0 A"),
+ (5.5, "5.5 A"),
+ (1100, "1.1 kA"),
+ (0.05, "50 mA"),
+ ])
+def test_eng_str_with_unit(input, expected):
+ assert expected == eng_str(input, unit = 'A')
@pytest.mark.parametrize("input,expected", [
(100, ''), (101, ''), (102, ''), (103, ''), (104, ''), (105, ''), (106, ''), (107, ''), (108, ''), (109, ''),
@@ -20,7 +40,7 @@ def test_eng_str(input, expected):
(130, ''), (131, ''), (132, ''), (133, ''), (134, ''), (135, ''), (136, ''), (137, ''), (138, ''), (139, ''),
])
def xx_test_eng_str2(input, expected):
- assert eng_str(input) == expected
+ assert expected == eng_str(input)
@pytest.mark.parametrize("input,expected", [
(10, '10'),
@@ -35,4 +55,4 @@ def xx_test_eng_str2(input, expected):
(19, '19'),
])
def xx_test_eng_str3(input, expected):
- assert eng_str(input) == expected
+ assert expected == eng_str(input)