Skip to content

Instantly share code, notes, and snippets.

@edgabaldi
Created April 9, 2019 15:17
Show Gist options
  • Save edgabaldi/f04981028bd2ed48750c68728360b5c4 to your computer and use it in GitHub Desktop.
Save edgabaldi/f04981028bd2ed48750c68728360b5c4 to your computer and use it in GitHub Desktop.
def almost_equal(self, checked, correct, significant_digits=1):
"""
Função Quase Igual
"""
precision = 0.1 ** significant_digits
return abs(checked - correct) < precision
class PolygonAlmostEqualTestCase(TestCase):
"""
Testa a função "quase igual"
"""
def setUp(self):
point = Point(lat=0, lon=0)
self.polygon = Polygon([point])
def test_almost_equal(self):
self.assertTrue(self.polygon.almost_equal(0, 0))
self.assertTrue(self.polygon.almost_equal(0, 0.09))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment