コード例 #1
0
def test_set_country_invalid_type(app):
    user = User('*****@*****.**', 'blah')

    with pytest.raises(TypeError) as e:
        user.country = 'SK'

    assert 'Country must be integer value from this set:' in str(e.value)
コード例 #2
0
def test_unset_country(app):
    user = User('*****@*****.**', 'blah', country=Country.SK)

    assert user.country is not None

    user.country = None

    assert user.zip_code is None
コード例 #3
0
def test_set_country(app):
    user = User('*****@*****.**', 'blah')

    assert user.country is None

    user.country = Country.SK

    assert user.country == Country.SK
コード例 #4
0
def test_set_country_out_of_range(app):
    user = User('*****@*****.**', 'blah')

    not_existing_country_value = 9

    assert not_existing_country_value not in [value.value for value in Country.__members__.values()]

    with pytest.raises(TypeError) as e:
        user.country = not_existing_country_value

    assert 'Country must be integer value from this set:' in str(e.value)