示例#1
0
 def test_dict_access(self):
     address = Address(line1='10, avenue des Champs Elysées',
                       postal_code='75008',
                       city_name='Paris',
                       country_code='FR')
     self.assertSequenceEqual(
         set([
             'line1',
             'line2',
             'postal_code',
             'city_name',
             'country_code',
             'subdivision_code',
         ]), set(address.keys()))
     self.assertEquals(len(address), 6)
     self.assertEquals(
         set([
             None, '10, avenue des Champs Elysées', '75008', 'Paris', 'FR'
         ]), set(address.values()))
     self.assertEquals(
         {
             'line1': '10, avenue des Champs Elysées',
             'line2': None,
             'postal_code': '75008',
             'city_name': 'Paris',
             'country_code': 'FR',
             'subdivision_code': None,
         }, dict(address.items()))
     for key in address:
         self.assertEquals(getattr(address, key), address[key])
示例#2
0
 def test_dict_access(self):
     address = Address(
         line1='10, avenue des Champs Elysées',
         postal_code='75008',
         city_name='Paris',
         country_code='FR')
     self.assertSequenceEqual(set([
         'line1',
         'line2',
         'postal_code',
         'city_name',
         'country_code',
         'subdivision_code',
     ]), set(address.keys()))
     self.assertEquals(len(address), 6)
     self.assertEquals(
         set([None, '10, avenue des Champs Elysées',
              '75008', 'Paris', 'FR']),
         set(address.values()))
     self.assertEquals({
         'line1': '10, avenue des Champs Elysées',
         'line2': None,
         'postal_code': '75008',
         'city_name': 'Paris',
         'country_code': 'FR',
         'subdivision_code': None,
     }, dict(address.items()))
     for key in address:
         self.assertEquals(getattr(address, key), address[key])
示例#3
0
    def test_dict_access(self) -> None:
        address = Address(
            line1="10, avenue des Champs Elysées",
            postal_code="75008",
            city_name="Paris",
            country_code="FR",
        )
        assert {
            "line1",
            "line2",
            "postal_code",
            "city_name",
            "country_code",
            "subdivision_code",
        } == set(address)

        assert len(address) == 6
        assert {"10, avenue des Champs Elysées", "75008", "Paris", "FR",
                None} == set(address.values())
        assert {
            "line1": "10, avenue des Champs Elysées",
            "line2": None,
            "postal_code": "75008",
            "city_name": "Paris",
            "country_code": "FR",
            "subdivision_code": None,
        } == dict(address.items())
        for key in address:
            assert getattr(address, key) == address[key]