fix test that failed in python2 due to changes to hash builtin

pull/158/head
Andrew Port 2021-09-23 00:15:37 -07:00
parent e0f212a334
commit 1b503a7b2f
1 changed files with 21 additions and 18 deletions

View File

@ -1,5 +1,7 @@
# External dependencies # External dependencies
from __future__ import division, absolute_import, print_function from __future__ import division, absolute_import, print_function
import sys
import unittest import unittest
from math import sqrt, pi from math import sqrt, pi
from operator import itemgetter from operator import itemgetter
@ -738,26 +740,27 @@ class TestPath(unittest.TestCase):
test_curves = [bezpath, bezpathz, path, pathz, lpath, qpath, cpath, test_curves = [bezpath, bezpathz, path, pathz, lpath, qpath, cpath,
apath, line1, arc1, arc2, cub1, cub2, quad3, linez] apath, line1, arc1, arc2, cub1, cub2, quad3, linez]
# this is necessary due to changes to the builtin `hash` function
if sys.version_info.major == 2:
expected_hashes = [ expected_hashes = [
-6073024107272494569, -5762846476463470127, -138736730317965290, -2005041722222729058,
-2519772625496438197, 8448700906794235291, -5178990533869800243, -4003140762934044601,
8726412907710383506, 8575549467429100514, 5166859065265868968, 1373103287265872323,
2132930052750006195, -1022491904150314631, 4188352014604112779, -5090374009174854814,
3112548573593977871, -7093907105533857815, 2036243740727202243, -8108488067585685407]
991446120749438306, else:
-5589397644574569777, expected_hashes = [
-4438808571483114580, -6073024107272494569, -2519772625496438197, 8726412907710383506,
-3125333407400456536, 2132930052750006195, 3112548573593977871, 991446120749438306,
-4418099728831808951, -5589397644574569777, -4438808571483114580, -3125333407400456536,
702646573139378041, -4418099728831808951, 702646573139378041, -6331016786776229094,
-6331016786776229094, 5053050772929443013, 6102272282813527681, -5385294438006156225,
5053050772929443013,
6102272282813527681,
-5385294438006156225,
] ]
for c, h in zip(test_curves, expected_hashes): for c, h in zip(test_curves, expected_hashes):
self.assertTrue(hash(c) == h, msg=f"hash {h} was expected for curve = {c}") if hash(c) != h:
from pdb import set_trace; set_trace()
self.assertTrue(hash(c) == h, msg="hash {} was expected for curve = {}".format(h, c))
def test_circle(self): def test_circle(self):
arc1 = Arc(0j, 100 + 100j, 0, 0, 0, 200 + 0j) arc1 = Arc(0j, 100 + 100j, 0, 0, 0, 200 + 0j)