mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #34676 -- Normalized Distance()/Area() exceptions for nonexistent units.
This commit is contained in:
committed by
Mariusz Felisiak
parent
650ce96782
commit
38cde27a89
@@ -6,9 +6,10 @@ and conversions. Here are some tests.
|
||||
import unittest
|
||||
|
||||
from django.contrib.gis.measure import A, Area, D, Distance
|
||||
from django.test import SimpleTestCase
|
||||
|
||||
|
||||
class DistanceTest(unittest.TestCase):
|
||||
class DistanceTest(SimpleTestCase):
|
||||
"Testing the Distance object"
|
||||
|
||||
def test_init(self):
|
||||
@@ -157,6 +158,13 @@ class DistanceTest(unittest.TestCase):
|
||||
with self.subTest(nm=nm):
|
||||
self.assertEqual(att, D.unit_attname(nm))
|
||||
|
||||
def test_unit_att_name_invalid(self):
|
||||
msg = "Unknown unit type: invalid-unit-name"
|
||||
with self.assertRaisesMessage(AttributeError, msg):
|
||||
D.unit_attname("invalid-unit-name")
|
||||
with self.assertRaisesMessage(AttributeError, msg):
|
||||
A.unit_attname("invalid-unit-name")
|
||||
|
||||
def test_hash(self):
|
||||
d1 = D(m=99)
|
||||
d2 = D(m=100)
|
||||
|
||||
Reference in New Issue
Block a user