import phonenumbers
from django.test import SimpleTestCase

from phonenumber_field.phonenumber import PhoneNumber


class PhoneNumberOrdering(SimpleTestCase):
    def test_ordering(self):
        phone1 = PhoneNumber.from_string("+33600000000")
        phone2 = PhoneNumber.from_string("+33600000001")
        self.assertLess(phone1, phone2)
        # Ordering is total.
        self.assertGreater(phone2, phone1)
        self.assertLessEqual(phone1, phone1)
        self.assertGreaterEqual(phone1, phone1)
        self.assertEqual(phone1, phone1)

    def test_ordering_with_phonenumbers(self):
        phone1 = PhoneNumber.from_string("+33600000000")
        phone2 = phonenumbers.parse("+33600000001")
        self.assertLess(phone1, phone2)

    def test_ordering_contains_None(self):
        phone1 = PhoneNumber.from_string("+33600000000")
        msg = "'<' not supported between instances of 'PhoneNumber' and 'NoneType'"
        for assertion in [
            self.assertLess,
            self.assertLessEqual,
            self.assertGreater,
            self.assertGreaterEqual,
        ]:
            with self.subTest(assertion):
                with self.assertRaisesMessage(TypeError, msg):
                    assertion(phone1, None)

    def test_ordering_with_invalid_value(self):
        phone1 = PhoneNumber.from_string("+33600000000")
        invalid = PhoneNumber.from_string("+1000000000")
        invalid_phonenumbers = phonenumbers.parse("+1000000000")
        for number in [invalid, invalid_phonenumbers]:
            with self.subTest(number):
                for p1, p2 in [[phone1, number], [number, phone1]]:
                    with self.subTest([p1, p2]):
                        with self.assertRaisesRegex(
                            ValueError, r"^Invalid phone number: "
                        ):
                            self.assertLess(p1, p2)

@@ -51,16 +51,35 @@
 TestCase
+, override_settings
 %0A%0Afrom p
@@ -128,16 +128,768 @@
 umber%0A%0A%0A
+class PhoneNumberTest(SimpleTestCase):%0A    def test_phonenumber_default_format(self):%0A        phone = PhoneNumber.from_string(%22+33612345678%22)%0A        # E164 by default.%0A        self.assertEqual(str(phone), %22+33612345678%22)%0A        with override_settings(PHONENUMBER_DEFAULT_FORMAT=%22E164%22):%0A            self.assertEqual(str(phone), %22+33612345678%22)%0A        with override_settings(PHONENUMBER_DEFAULT_FORMAT=%22INTERNATIONAL%22):%0A            self.assertEqual(str(phone), %22+33 6 12 34 56 78%22)%0A        with override_settings(PHONENUMBER_DEFAULT_FORMAT=%22NATIONAL%22):%0A            self.assertEqual(str(phone), %2206 12 34 56 78%22)%0A        with override_settings(PHONENUMBER_DEFAULT_FORMAT=%22RFC3966%22):%0A            self.assertEqual(str(phone), %22tel:+33-6-12-34-56-78%22)%0A%0A%0A
 class Ph

Add tests for PHONENUMBER_DEFAULT_FORMAT