<s> """<STR_LIT>""" <EOL> from decimal import Decimal <EOL> from django import VERSION <EOL> from django . core . exceptions import ValidationError <EOL> from django . db . models import F , Q <EOL> from django . utils . six import PY2 <EOL> import moneyed <EOL> import pytest <EOL> from moneyed import Money <EOL> from djmoney . models . fields import AUTO_CONVERT_MONEY , MoneyPatched <EOL> from . testapp . models import ( <EOL> AbstractModel , <EOL> BaseModel , <EOL> InheritedModel , <EOL> InheritorModel , <EOL> ModelRelatedToModelWithMoney , <EOL> ModelWithChoicesMoneyField , <EOL> ModelWithDefaultAsDecimal , <EOL> ModelWithDefaultAsFloat , <EOL> ModelWithDefaultAsInt , <EOL> ModelWithDefaultAsMoney , <EOL> ModelWithDefaultAsString , <EOL> ModelWithDefaultAsStringWithCurrency , <EOL> ModelWithNonMoneyField , <EOL> ModelWithTwoMoneyFields , <EOL> ModelWithVanillaMoneyField , <EOL> NullMoneyFieldModel , <EOL> ProxyModel , <EOL> SimpleModel , <EOL> ) <EOL> if VERSION >= ( <NUM_LIT:1> , <NUM_LIT:7> ) : <EOL> from django . db . migrations . writer import MigrationWriter <EOL> pytestmark = pytest . mark . django_db <EOL> class TestVanillaMoneyField : <EOL> @ pytest . mark . parametrize ( <EOL> '<STR_LIT>' , <EOL> ( <EOL> ( ModelWithVanillaMoneyField , { '<STR_LIT>' : Money ( '<STR_LIT>' ) } , Money ( '<STR_LIT>' ) ) , <EOL> ( BaseModel , { } , Money ( <NUM_LIT:0> , '<STR_LIT>' ) ) , <EOL> ( BaseModel , { '<STR_LIT>' : '<STR_LIT>' } , Money ( '<STR_LIT>' , '<STR_LIT>' ) ) , <EOL> ( BaseModel , { '<STR_LIT>' : Money ( '<STR_LIT>' , '<STR_LIT>' ) } , Money ( '<STR_LIT>' , '<STR_LIT>' ) ) , <EOL> ( BaseModel , { '<STR_LIT>' : ( '<STR_LIT>' , '<STR_LIT>' ) } , Money ( '<STR_LIT>' , '<STR_LIT>' ) ) , <EOL> ( BaseModel , { '<STR_LIT>' : ( <NUM_LIT> , '<STR_LIT>' ) } , Money ( '<STR_LIT>' , '<STR_LIT>' ) ) , <EOL> ( ModelWithDefaultAsMoney , { } , Money ( '<STR_LIT>' , '<STR_LIT>' ) ) , <EOL> ( ModelWithDefaultAsFloat , { } , Money ( '<STR_LIT>' , '<STR_LIT>' ) ) , <EOL> ( ModelWithDefaultAsStringWithCurrency , { } , Money ( '<STR_LIT>' , '<STR_LIT>' ) ) , <EOL> ( ModelWithDefaultAsString , { } , Money ( '<STR_LIT>' , '<STR_LIT>' ) ) , <EOL> ( ModelWithDefaultAsInt , { } , Money ( '<STR_LIT>' , '<STR_LIT>' ) ) , <EOL> ( ModelWithDefaultAsDecimal , { } , Money ( '<STR_LIT>' , '<STR_LIT>' ) ) , <EOL> ) <EOL> ) <EOL> def test_create_defaults ( self , model_class , kwargs , expected ) : <EOL> instance = model_class . objects . create ( ** kwargs ) <EOL> assert instance . money == expected <EOL> retrieved = model_class . objects . get ( pk = instance . pk ) <EOL> assert retrieved . money == expected <EOL> @ pytest . mark . parametrize ( <EOL> '<STR_LIT:value>' , <EOL> ( <EOL> ( <NUM_LIT:1> , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( <NUM_LIT:1> , None ) , <EOL> ( <NUM_LIT:1> , ) , <EOL> ) <EOL> ) <EOL> def test_invalid_values ( self , value ) : <EOL> with pytest . raises ( ValidationError ) : <EOL> BaseModel . objects . create ( money = value ) <EOL> @ pytest . mark . parametrize ( '<STR_LIT>' , ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> def test_save_new_value ( self , field_name ) : <EOL> ModelWithVanillaMoneyField . objects . create ( ** { field_name : Money ( '<STR_LIT>' ) } ) <EOL> retrieved = ModelWithVanillaMoneyField . objects . get ( ) <EOL> setattr ( retrieved , field_name , Money ( <NUM_LIT:1> , moneyed . DKK ) ) <EOL> retrieved . save ( ) <EOL> retrieved = ModelWithVanillaMoneyField . objects . get ( ) <EOL> assert getattr ( retrieved , field_name ) == Money ( <NUM_LIT:1> , moneyed . DKK ) <EOL> def test_rounding ( self ) : <EOL> money = Money ( '<STR_LIT>' ) <EOL> instance = ModelWithVanillaMoneyField . objects . create ( money = money ) <EOL> retrieved = ModelWithVanillaMoneyField . objects . get ( pk = instance . pk ) <EOL> assert retrieved . money == Money ( '<STR_LIT>' ) <EOL> @ pytest . mark . parametrize ( <EOL> '<STR_LIT>' , <EOL> ( <EOL> ( Q ( amount1 = F ( '<STR_LIT>' ) ) , <NUM_LIT:1> ) , <EOL> ( Q ( amount1__gt = F ( '<STR_LIT>' ) ) , <NUM_LIT:2> ) , <EOL> ( Q ( amount1 = Money ( <NUM_LIT:1> , '<STR_LIT>' ) ) | Q ( amount2 = Money ( <NUM_LIT:0> , '<STR_LIT>' ) ) , <NUM_LIT:3> ) , <EOL> ( Q ( amount1 = Money ( <NUM_LIT:1> , '<STR_LIT>' ) ) | Q ( amount1 = Money ( <NUM_LIT:4> , '<STR_LIT>' ) ) | Q ( amount2 = Money ( <NUM_LIT:0> , '<STR_LIT>' ) ) , <NUM_LIT:2> ) , <EOL> ( Q ( amount1 = Money ( <NUM_LIT:1> , '<STR_LIT>' ) ) | Q ( amount1 = Money ( <NUM_LIT:5> , '<STR_LIT>' ) ) | Q ( amount2 = Money ( <NUM_LIT:0> , '<STR_LIT>' ) ) , <NUM_LIT:3> ) , <EOL> ( Q ( amount1 = Money ( <NUM_LIT:1> , '<STR_LIT>' ) ) | Q ( amount1 = Money ( <NUM_LIT:4> , '<STR_LIT>' ) , amount2 = Money ( <NUM_LIT:0> , '<STR_LIT>' ) ) , <NUM_LIT:2> ) , <EOL> ( Q ( amount1 = Money ( <NUM_LIT:1> , '<STR_LIT>' ) ) | Q ( amount1__gt = Money ( <NUM_LIT:4> , '<STR_LIT>' ) , amount2 = Money ( <NUM_LIT:0> , '<STR_LIT>' ) ) , <NUM_LIT:1> ) , <EOL> ( Q ( amount1 = Money ( <NUM_LIT:1> , '<STR_LIT>' ) ) | Q ( amount1__gte = Money ( <NUM_LIT:4> , '<STR_LIT>' ) , amount2 = Money ( <NUM_LIT:0> , '<STR_LIT>' ) ) , <NUM_LIT:2> ) , <EOL> ) <EOL> ) <EOL> def test_comparison_lookup ( self , filters , expected_count ) : <EOL> ModelWithTwoMoneyFields . objects . bulk_create ( ( <EOL> ModelWithTwoMoneyFields ( amount1 = Money ( <NUM_LIT:1> , '<STR_LIT>' ) , amount2 = Money ( <NUM_LIT:2> , '<STR_LIT>' ) ) , <EOL> ModelWithTwoMoneyFields ( amount1 = Money ( <NUM_LIT:2> , '<STR_LIT>' ) , amount2 = Money ( <NUM_LIT:0> , '<STR_LIT>' ) ) , <EOL> ModelWithTwoMoneyFields ( amount1 = Money ( <NUM_LIT:3> , '<STR_LIT>' ) , amount2 = Money ( <NUM_LIT:0> , '<STR_LIT>' ) ) , <EOL> ModelWithTwoMoneyFields ( amount1 = Money ( <NUM_LIT:4> , '<STR_LIT>' ) , amount2 = Money ( <NUM_LIT:0> , '<STR_LIT>' ) ) , <EOL> ModelWithTwoMoneyFields ( amount1 = Money ( <NUM_LIT:5> , '<STR_LIT>' ) , amount2 = Money ( <NUM_LIT:5> , '<STR_LIT>' ) ) , <EOL> ) ) <EOL> assert ModelWithTwoMoneyFields . objects . filter ( filters ) . count ( ) == expected_count <EOL> def test_exact_match ( self ) : <EOL> money = Money ( '<STR_LIT>' ) <EOL> instance = ModelWithVanillaMoneyField . objects . create ( money = money ) <EOL> retrieved = ModelWithVanillaMoneyField . objects . get ( money = money ) <EOL> assert instance . pk == retrieved . pk <EOL> def test_range_search ( self ) : <EOL> money = Money ( '<STR_LIT:3>' ) <EOL> instance = ModelWithVanillaMoneyField . objects . create ( money = Money ( '<STR_LIT>' ) ) <EOL> retrieved = ModelWithVanillaMoneyField . objects . get ( money__gt = money ) <EOL> assert instance . pk == retrieved . pk <EOL> assert ModelWithVanillaMoneyField . objects . filter ( money__lt = money ) . count ( ) == <NUM_LIT:0> <EOL> @ pytest . mark . parametrize ( '<STR_LIT>' , ( ModelWithVanillaMoneyField , ModelWithChoicesMoneyField ) ) <EOL> def test_currency_querying ( self , model_class ) : <EOL> model_class . objects . create ( money = Money ( '<STR_LIT>' , moneyed . ZWN ) ) <EOL> assert model_class . objects . filter ( money__lt = Money ( '<STR_LIT>' , moneyed . USD ) ) . count ( ) == <NUM_LIT:0> <EOL> assert model_class . objects . filter ( money__lt = Money ( '<STR_LIT>' , moneyed . ZWN ) ) . count ( ) == <NUM_LIT:1> <EOL> def test_isnull_lookup ( self ) : <EOL> NullMoneyFieldModel . objects . create ( field = None ) <EOL> NullMoneyFieldModel . objects . create ( field = Money ( <NUM_LIT:100> , '<STR_LIT>' ) ) <EOL> queryset = NullMoneyFieldModel . objects . filter ( field = None ) <EOL> assert queryset . count ( ) == <NUM_LIT:1> <EOL> def test_null_default ( self ) : <EOL> instance = NullMoneyFieldModel . objects . create ( ) <EOL> assert instance . field is None <EOL> @ pytest . mark . parametrize ( <EOL> '<STR_LIT>' , <EOL> ( <EOL> ( { '<STR_LIT>' : '<STR_LIT>' } , '<STR_LIT>' ) , <EOL> ( { '<STR_LIT>' : Money ( <NUM_LIT:0> , '<STR_LIT>' ) } , '<STR_LIT>' ) <EOL> ) <EOL> ) <EOL> def test_get_or_create_respects_currency ( self , kwargs , currency ) : <EOL> instance , created = ModelWithVanillaMoneyField . objects . get_or_create ( ** kwargs ) <EOL> assert str ( instance . money . currency ) == currency , '<STR_LIT>' <EOL> class TestFExpressions : <EOL> parametrize_f_objects = pytest . mark . parametrize ( <EOL> '<STR_LIT>' , <EOL> ( <EOL> ( F ( '<STR_LIT>' ) + Money ( <NUM_LIT:100> , '<STR_LIT>' ) , Money ( <NUM_LIT:200> , '<STR_LIT>' ) ) , <EOL> ( F ( '<STR_LIT>' ) - Money ( <NUM_LIT:100> , '<STR_LIT>' ) , Money ( <NUM_LIT:0> , '<STR_LIT>' ) ) , <EOL> ( F ( '<STR_LIT>' ) * <NUM_LIT:2> , Money ( <NUM_LIT:200> , '<STR_LIT>' ) ) , <EOL> ( F ( '<STR_LIT>' ) * F ( '<STR_LIT>' ) , Money ( <NUM_LIT:200> , '<STR_LIT>' ) ) , <EOL> ( F ( '<STR_LIT>' ) / <NUM_LIT:2> , Money ( <NUM_LIT:50> , '<STR_LIT>' ) ) , <EOL> ( F ( '<STR_LIT>' ) % <NUM_LIT> , Money ( <NUM_LIT:2> , '<STR_LIT>' ) ) , <EOL> ( F ( '<STR_LIT>' ) / F ( '<STR_LIT>' ) , Money ( <NUM_LIT:50> , '<STR_LIT>' ) ) , <EOL> ( F ( '<STR_LIT>' ) + F ( '<STR_LIT>' ) , Money ( <NUM_LIT:200> , '<STR_LIT>' ) ) , <EOL> ( F ( '<STR_LIT>' ) - F ( '<STR_LIT>' ) , Money ( <NUM_LIT:0> , '<STR_LIT>' ) ) , <EOL> ) <EOL> ) <EOL> @ parametrize_f_objects <EOL> def test_save ( self , f_obj , expected ) : <EOL> instance = ModelWithVanillaMoneyField . objects . create ( money = Money ( <NUM_LIT:100> , '<STR_LIT>' ) , integer = <NUM_LIT:2> ) <EOL> instance . money = f_obj <EOL> instance . save ( ) <EOL> instance = ModelWithVanillaMoneyField . objects . get ( pk = instance . pk ) <EOL> assert instance . money == expected <EOL> @ parametrize_f_objects <EOL> def test_f_update ( self , f_obj , expected ) : <EOL> instance = ModelWithVanillaMoneyField . objects . create ( money = Money ( <NUM_LIT:100> , '<STR_LIT>' ) , integer = <NUM_LIT:2> ) <EOL> ModelWithVanillaMoneyField . objects . update ( money = f_obj ) <EOL> instance = ModelWithVanillaMoneyField . objects . get ( pk = instance . pk ) <EOL> assert instance . money == expected <EOL> @ pytest . mark . parametrize ( <EOL> '<STR_LIT>' , <EOL> ( <EOL> ( <EOL> { '<STR_LIT>' : Money ( <NUM_LIT:100> , '<STR_LIT>' ) , '<STR_LIT>' : Money ( <NUM_LIT:100> , '<STR_LIT>' ) } , <EOL> { '<STR_LIT>' : F ( '<STR_LIT>' ) } , <EOL> True <EOL> ) , <EOL> ( <EOL> { '<STR_LIT>' : Money ( <NUM_LIT:100> , '<STR_LIT>' ) , '<STR_LIT>' : Money ( <NUM_LIT:100> , '<STR_LIT>' ) } , <EOL> { '<STR_LIT>' : F ( '<STR_LIT>' ) } , <EOL> True <EOL> ) , <EOL> ( <EOL> { '<STR_LIT>' : Money ( <NUM_LIT:100> , '<STR_LIT>' ) , '<STR_LIT>' : Money ( <NUM_LIT:100> , '<STR_LIT>' ) } , <EOL> { '<STR_LIT>' : F ( '<STR_LIT>' ) } , <EOL> False <EOL> ) , <EOL> ( <EOL> { '<STR_LIT>' : Money ( <NUM_LIT:50> , '<STR_LIT>' ) , '<STR_LIT>' : Money ( <NUM_LIT:100> , '<STR_LIT>' ) } , <EOL> { '<STR_LIT>' : F ( '<STR_LIT>' ) * <NUM_LIT:2> } , <EOL> True <EOL> ) , <EOL> ( <EOL> { '<STR_LIT>' : Money ( <NUM_LIT:50> , '<STR_LIT>' ) , '<STR_LIT>' : Money ( <NUM_LIT:100> , '<STR_LIT>' ) } , <EOL> { '<STR_LIT>' : F ( '<STR_LIT>' ) + Money ( <NUM_LIT:50> , '<STR_LIT>' ) } , <EOL> True <EOL> ) , <EOL> ( <EOL> { '<STR_LIT>' : Money ( <NUM_LIT:50> , '<STR_LIT>' ) , '<STR_LIT>' : Money ( <NUM_LIT:100> , '<STR_LIT>' ) } , <EOL> { '<STR_LIT>' : F ( '<STR_LIT>' ) * <NUM_LIT:2> } , <EOL> False <EOL> ) , <EOL> ( <EOL> { '<STR_LIT>' : Money ( <NUM_LIT:50> , '<STR_LIT>' ) , '<STR_LIT>' : Money ( <NUM_LIT:100> , '<STR_LIT>' ) } , <EOL> { '<STR_LIT>' : F ( '<STR_LIT>' ) + Money ( <NUM_LIT:50> , '<STR_LIT>' ) } , <EOL> False <EOL> ) , <EOL> ) <EOL> ) <EOL> def test_filtration ( self , create_kwargs , filter_value , in_result ) : <EOL> instance = ModelWithVanillaMoneyField . objects . create ( ** create_kwargs ) <EOL> assert ( instance in ModelWithVanillaMoneyField . objects . filter ( ** filter_value ) ) is in_result <EOL> @ pytest . mark . skipif ( VERSION < ( <NUM_LIT:1> , <NUM_LIT:5> ) , reason = '<STR_LIT>' ) <EOL> def test_update_fields_save ( self ) : <EOL> instance = ModelWithVanillaMoneyField . objects . create ( money = Money ( <NUM_LIT:100> , '<STR_LIT>' ) , integer = <NUM_LIT:2> ) <EOL> instance . money = F ( '<STR_LIT>' ) + Money ( <NUM_LIT:100> , '<STR_LIT>' ) <EOL> instance . save ( update_fields = [ '<STR_LIT>' ] ) <EOL> instance = ModelWithVanillaMoneyField . objects . get ( pk = instance . pk ) <EOL> assert instance . money == Money ( <NUM_LIT:200> , '<STR_LIT>' ) <EOL> INVALID_EXPRESSIONS = [ <EOL> F ( '<STR_LIT>' ) + Money ( <NUM_LIT:100> , '<STR_LIT>' ) , <EOL> F ( '<STR_LIT>' ) * F ( '<STR_LIT>' ) , <EOL> F ( '<STR_LIT>' ) / F ( '<STR_LIT>' ) , <EOL> F ( '<STR_LIT>' ) % F ( '<STR_LIT>' ) , <EOL> F ( '<STR_LIT>' ) + F ( '<STR_LIT>' ) , <EOL> F ( '<STR_LIT>' ) + F ( '<STR_LIT>' ) , <EOL> ] <EOL> if VERSION >= ( <NUM_LIT:1> , <NUM_LIT:7> ) : <EOL> INVALID_EXPRESSIONS . extend ( [ <EOL> F ( '<STR_LIT>' ) ** F ( '<STR_LIT>' ) , <EOL> F ( '<STR_LIT>' ) ** F ( '<STR_LIT>' ) , <EOL> F ( '<STR_LIT>' ) ** <NUM_LIT:2> , <EOL> ] ) <EOL> @ pytest . mark . parametrize ( '<STR_LIT>' , INVALID_EXPRESSIONS ) <EOL> def test_invalid_expressions_access ( self , f_obj ) : <EOL> instance = ModelWithVanillaMoneyField . objects . create ( money = Money ( <NUM_LIT:100> , '<STR_LIT>' ) ) <EOL> with pytest . raises ( ValidationError ) : <EOL> instance . money = f_obj <EOL> def test_find_models_related_to_money_models ( ) : <EOL> moneyModel = ModelWithVanillaMoneyField . objects . create ( money = Money ( '<STR_LIT>' , moneyed . ZWN ) ) <EOL> ModelRelatedToModelWithMoney . objects . create ( moneyModel = moneyModel ) <EOL> ModelRelatedToModelWithMoney . objects . get ( moneyModel__money = Money ( '<STR_LIT>' , moneyed . ZWN ) ) <EOL> ModelRelatedToModelWithMoney . objects . get ( moneyModel__money__lt = Money ( '<STR_LIT>' , moneyed . ZWN ) ) <EOL> def test_allow_expression_nodes_without_money ( ) : <EOL> """<STR_LIT>""" <EOL> desc = '<STR_LIT>' <EOL> ModelWithNonMoneyField . objects . create ( money = Money ( <NUM_LIT> ) , desc = desc ) <EOL> instance = ModelWithNonMoneyField . objects . filter ( desc = F ( '<STR_LIT>' ) ) . get ( ) <EOL> assert instance . desc == desc <EOL> def test_base_model ( ) : <EOL> assert BaseModel . objects . model == BaseModel <EOL> @ pytest . mark . parametrize ( '<STR_LIT>' , ( InheritedModel , InheritorModel ) ) <EOL> class TestInheritance : <EOL> """<STR_LIT>""" <EOL> def test_model ( self , model_class ) : <EOL> assert model_class . objects . model == model_class <EOL> def test_fields ( self , model_class ) : <EOL> first_value = Money ( '<STR_LIT>' , moneyed . ZWN ) <EOL> second_value = Money ( '<STR_LIT>' , moneyed . USD ) <EOL> instance = model_class . objects . create ( money = first_value , second_field = second_value ) <EOL> assert instance . money == first_value <EOL> assert instance . second_field == second_value <EOL> class TestManager : <EOL> def test_manager ( self ) : <EOL> assert hasattr ( SimpleModel , '<STR_LIT>' ) <EOL> def test_objects_creation ( self ) : <EOL> SimpleModel . objects . create ( money = Money ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> assert SimpleModel . objects . count ( ) == <NUM_LIT:1> <EOL> class TestProxyModel : <EOL> def test_instances ( self ) : <EOL> ProxyModel . objects . create ( money = Money ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> assert isinstance ( ProxyModel . objects . get ( pk = <NUM_LIT:1> ) , ProxyModel ) <EOL> def test_patching ( self ) : <EOL> ProxyModel . objects . create ( money = Money ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> assert ProxyModel . objects . filter ( money__gt = Money ( '<STR_LIT>' , '<STR_LIT>' ) ) . count ( ) == <NUM_LIT:0> <EOL> rates_is_available = pytest . mark . skipif ( <EOL> not AUTO_CONVERT_MONEY , <EOL> reason = '<STR_LIT>' <EOL> ) <EOL> pytest_plugins = '<STR_LIT>' <EOL> class TestDifferentCurrencies : <EOL> """<STR_LIT>""" <EOL> @ rates_is_available <EOL> @ pytest . mark . usefixtures ( '<STR_LIT>' ) <EOL> def test_add ( self ) : <EOL> result = MoneyPatched ( <NUM_LIT:10> , '<STR_LIT>' ) + Money ( <NUM_LIT:1> , '<STR_LIT>' ) <EOL> assert Decimal ( str ( round ( result . amount , <NUM_LIT:2> ) ) ) == Decimal ( '<STR_LIT>' ) <EOL> assert result . currency == moneyed . EUR <EOL> @ rates_is_available <EOL> @ pytest . mark . usefixtures ( '<STR_LIT>' ) <EOL> def test_sub ( self ) : <EOL> result = MoneyPatched ( <NUM_LIT:10> , '<STR_LIT>' ) - Money ( <NUM_LIT:1> , '<STR_LIT>' ) <EOL> assert Decimal ( str ( round ( result . amount , <NUM_LIT:2> ) ) ) == Decimal ( '<STR_LIT>' ) <EOL> assert result . currency == moneyed . EUR <EOL> def test_eq ( self ) : <EOL> assert MoneyPatched ( <NUM_LIT:1> , '<STR_LIT>' ) == Money ( <NUM_LIT:1> , '<STR_LIT>' ) <EOL> def test_ne ( self ) : <EOL> assert MoneyPatched ( <NUM_LIT:1> , '<STR_LIT>' ) != Money ( <NUM_LIT:2> , '<STR_LIT>' ) <EOL> def test_exception ( self ) : <EOL> with pytest . raises ( TypeError ) : <EOL> MoneyPatched ( <NUM_LIT:10> , '<STR_LIT>' ) == Money ( <NUM_LIT:10> , '<STR_LIT>' ) <EOL> @ pytest . mark . parametrize ( <EOL> '<STR_LIT>' , ( <EOL> pytest . mark . xfail ( VERSION >= ( <NUM_LIT:1> , <NUM_LIT:9> ) , reason = '<STR_LIT>' ) ( True ) , <EOL> False <EOL> ) <EOL> ) <EOL> def test_app_is_installed ( self , testdir , rates_installed ) : <EOL> """<STR_LIT>""" <EOL> installed_apps = [ '<STR_LIT>' ] <EOL> if rates_installed : <EOL> installed_apps . append ( '<STR_LIT>' ) <EOL> testdir . makepyfile ( test_settings = '''<STR_LIT>''' % installed_apps ) <EOL> testdir . makepyfile ( '''<STR_LIT>''' % rates_installed ) <EOL> result = testdir . runpytest_subprocess ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> assert '<STR_LIT>' in result . stdout . lines <EOL> @ pytest . mark . parametrize ( <EOL> '<STR_LIT>' , ( <EOL> AbstractModel , <EOL> ModelWithNonMoneyField , <EOL> InheritorModel , <EOL> InheritedModel , <EOL> ProxyModel , <EOL> ) <EOL> ) <EOL> def test_manager_instance_access ( model_class ) : <EOL> with pytest . raises ( AttributeError ) : <EOL> model_class ( ) . objects . all ( ) <EOL> @ pytest . mark . skipif ( VERSION >= ( <NUM_LIT:1> , <NUM_LIT:10> ) , reason = '<STR_LIT>' ) <EOL> def test_get_field_by_name ( ) : <EOL> assert BaseModel . _meta . get_field_by_name ( '<STR_LIT>' ) [ <NUM_LIT:0> ] . __class__ . __name__ == '<STR_LIT>' <EOL> assert BaseModel . _meta . get_field_by_name ( '<STR_LIT>' ) [ <NUM_LIT:0> ] . __class__ . __name__ == '<STR_LIT>' <EOL> def test_different_hashes ( ) : <EOL> money = BaseModel . _meta . get_field ( '<STR_LIT>' ) <EOL> money_currency = BaseModel . _meta . get_field ( '<STR_LIT>' ) <EOL> assert hash ( money ) != hash ( money_currency ) <EOL> @ pytest . mark . skipif ( VERSION < ( <NUM_LIT:1> , <NUM_LIT:7> ) , reason = '<STR_LIT>' ) <EOL> def test_migration_serialization ( ) : <EOL> imports = set ( [ '<STR_LIT>' ] ) <EOL> if PY2 : <EOL> serialized = '<STR_LIT>' <EOL> else : <EOL> serialized = '<STR_LIT>' <EOL> assert MigrationWriter . serialize ( MoneyPatched ( <NUM_LIT:100> , '<STR_LIT>' ) ) == ( serialized , imports ) </s>
