aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ee/__init__.py4
-rw-r--r--test/test_EeVal.py9
2 files changed, 11 insertions, 2 deletions
diff --git a/src/ee/__init__.py b/src/ee/__init__.py
index 0450c40..1eb79d0 100644
--- a/src/ee/__init__.py
+++ b/src/ee/__init__.py
@@ -60,10 +60,10 @@ class EeVal(object):
return self._unit
def __eq__(self, other):
- return ((self._value, self._unit) == (other._value, other._unit))
+ return ((self.__float__(), self._unit) == (other.__float__(), other._unit))
def __lt__(self, other):
- return ((self._value, self._unit) < (other._value, other._unit))
+ return ((self.__float__(), self._unit) < (other.__float__(), other._unit))
def __str__(self):
return eng_str(self.__float__(), self._unit)
diff --git a/test/test_EeVal.py b/test/test_EeVal.py
new file mode 100644
index 0000000..c4254fb
--- /dev/null
+++ b/test/test_EeVal.py
@@ -0,0 +1,9 @@
+from ee import EeVal
+
+def test_ordering():
+ p100 = EeVal('100 p')
+ n100 = EeVal('100 n')
+ u1 = EeVal('1u')
+ assert n100 > p100
+ assert p100 < n100
+ assert [p100, n100, u1] == sorted([p100, u1, n100])