MAINT: Ensure the sign of the result is positive

This commit is contained in:
Richard Frank
2013-09-23 16:12:17 -04:00
parent b4836b976e
commit 599ff1ad8a
2 changed files with 10 additions and 1 deletions
+6
View File
@@ -1,3 +1,5 @@
import math
from nose_parameterized import parameterized
from unittest import TestCase
@@ -16,6 +18,8 @@ class BlotterTestCase(TestCase):
def test_round_for_minimum_price_variation_buy(self, price, expected):
result = round_for_minimum_price_variation(price, is_buy=True)
self.assertEqual(result, expected)
self.assertEqual(math.copysign(1.0, result),
math.copysign(1.0, expected))
@parameterized.expand([(0.00, 0.00),
(0.01, 0.01),
@@ -27,3 +31,5 @@ class BlotterTestCase(TestCase):
def test_round_for_minimum_price_variation_sell(self, price, expected):
result = round_for_minimum_price_variation(price, is_buy=False)
self.assertEqual(result, expected)
self.assertEqual(math.copysign(1.0, result),
math.copysign(1.0, expected))