Here are the examples of the python api sqlalchemy_utils.Country taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
10 Examples
3
Example 1
def test_constructor_with_wrong_type(self):
with pytest.raises(TypeError) as e:
Country(None)
assert str(e.value) == (
"Country() argument must be a string or a country, not 'NoneType'"
)
3
Example 2
def test_constructor_with_invalid_code(self):
with pytest.raises(ValueError) as e:
Country('SomeUnknownCode')
assert str(e.value) == (
'Could not convert string to country code: SomeUnknownCode'
)
3
Example 3
def test_parameter_processing(self, session, User):
user = User(
country=Country(u'FI')
)
session.add(user)
session.commit()
user = session.query(User).first()
assert user.country.name == u'Finland'
0
Example 4
def test_init(self):
assert Country(u'FI') == Country(Country(u'FI'))
0
Example 5
def test_equality_operator(self):
assert Country(u'FI') == u'FI'
assert u'FI' == Country(u'FI')
assert Country(u'FI') == Country(u'FI')
0
Example 6
def test_non_equality_operator(self):
assert Country(u'FI') != u'sv'
assert not (Country(u'FI') != u'FI')
0
Example 7
def test_hash(self):
return hash(Country('FI')) == hash('FI')
0
Example 8
def test_repr(self):
return repr(Country('FI')) == "Country('FI')"
0
Example 9
def test_unicode(self):
country = Country('FI')
assert six.text_type(country) == u'Finland'
0
Example 10
def test_str(self):
country = Country('FI')
assert str(country) == 'Finland'