<s> from django . forms import TextInput , Media , TextInput , CharField , Form , MultiWidget <EOL> from django . template import Template , Context <EOL> from django . test import TestCase <EOL> from django . test . utils import override_settings <EOL> @ override_settings ( <EOL> STATIC_URL = None , <EOL> MEDIA_URL = '<STR_LIT>' , <EOL> ) <EOL> class FormsMediaTestCase ( TestCase ) : <EOL> """<STR_LIT>""" <EOL> def test_construction ( self ) : <EOL> m = Media ( css = { '<STR_LIT:all>' : ( '<STR_LIT>' , '<STR_LIT>' ) } , js = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> self . assertEqual ( str ( m ) , """<STR_LIT>""" ) <EOL> class Foo : <EOL> css = { <EOL> '<STR_LIT:all>' : ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> } <EOL> js = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> m3 = Media ( Foo ) <EOL> self . assertEqual ( str ( m3 ) , """<STR_LIT>""" ) <EOL> class MyWidget ( TextInput ) : <EOL> pass <EOL> w = MyWidget ( ) <EOL> self . assertEqual ( str ( w . media ) , '<STR_LIT>' ) <EOL> def test_media_dsl ( self ) : <EOL> class MyWidget1 ( TextInput ) : <EOL> class Media : <EOL> css = { <EOL> '<STR_LIT:all>' : ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> } <EOL> js = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> w1 = MyWidget1 ( ) <EOL> self . assertEqual ( str ( w1 . media ) , """<STR_LIT>""" ) <EOL> self . assertEqual ( str ( w1 . media [ '<STR_LIT>' ] ) , """<STR_LIT>""" ) <EOL> self . assertEqual ( str ( w1 . media [ '<STR_LIT>' ] ) , """<STR_LIT>""" ) <EOL> def test_combine_media ( self ) : <EOL> class MyWidget1 ( TextInput ) : <EOL> class Media : <EOL> css = { <EOL> '<STR_LIT:all>' : ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> } <EOL> js = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class MyWidget2 ( TextInput ) : <EOL> class Media : <EOL> css = { <EOL> '<STR_LIT:all>' : ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> } <EOL> js = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> class MyWidget3 ( TextInput ) : <EOL> class Media : <EOL> css = { <EOL> '<STR_LIT:all>' : ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> } <EOL> js = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> w1 = MyWidget1 ( ) <EOL> w2 = MyWidget2 ( ) <EOL> w3 = MyWidget3 ( ) <EOL> self . assertEqual ( str ( w1 . media + w2 . media + w3 . media ) , """<STR_LIT>""" ) <EOL> self . assertEqual ( str ( w1 . media ) , """<STR_LIT>""" ) <EOL> class MyWidget4 ( TextInput ) : <EOL> class Media : <EOL> css = { '<STR_LIT:all>' : ( '<STR_LIT>' , '<STR_LIT>' ) } <EOL> js = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> w4 = MyWidget4 ( ) <EOL> self . assertEqual ( str ( w4 . media ) , """<STR_LIT>""" ) <EOL> def test_media_property ( self ) : <EOL> class MyWidget4 ( TextInput ) : <EOL> def _media ( self ) : <EOL> return Media ( css = { '<STR_LIT:all>' : ( '<STR_LIT>' , ) } , js = ( '<STR_LIT>' , ) ) <EOL> media = property ( _media ) <EOL> w4 = MyWidget4 ( ) <EOL> self . assertEqual ( str ( w4 . media ) , """<STR_LIT>""" ) <EOL> class MyWidget5 ( MyWidget4 ) : <EOL> def _media ( self ) : <EOL> return super ( MyWidget5 , self ) . media + Media ( css = { '<STR_LIT:all>' : ( '<STR_LIT>' , ) } , js = ( '<STR_LIT>' , ) ) <EOL> media = property ( _media ) <EOL> w5 = MyWidget5 ( ) <EOL> self . assertEqual ( str ( w5 . media ) , """<STR_LIT>""" ) <EOL> def test_media_property_parent_references ( self ) : <EOL> class MyWidget1 ( TextInput ) : <EOL> class Media : <EOL> css = { <EOL> '<STR_LIT:all>' : ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> } <EOL> js = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class MyWidget6 ( MyWidget1 ) : <EOL> def _media ( self ) : <EOL> return super ( MyWidget6 , self ) . media + Media ( css = { '<STR_LIT:all>' : ( '<STR_LIT>' , ) } , js = ( '<STR_LIT>' , ) ) <EOL> media = property ( _media ) <EOL> w6 = MyWidget6 ( ) <EOL> self . assertEqual ( str ( w6 . media ) , """<STR_LIT>""" ) <EOL> def test_media_inheritance ( self ) : <EOL> class MyWidget1 ( TextInput ) : <EOL> class Media : <EOL> css = { <EOL> '<STR_LIT:all>' : ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> } <EOL> js = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class MyWidget7 ( MyWidget1 ) : <EOL> pass <EOL> w7 = MyWidget7 ( ) <EOL> self . assertEqual ( str ( w7 . media ) , """<STR_LIT>""" ) <EOL> class MyWidget8 ( MyWidget1 ) : <EOL> class Media : <EOL> css = { <EOL> '<STR_LIT:all>' : ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> } <EOL> js = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> w8 = MyWidget8 ( ) <EOL> self . assertEqual ( str ( w8 . media ) , """<STR_LIT>""" ) <EOL> def test_media_inheritance_from_property ( self ) : <EOL> class MyWidget1 ( TextInput ) : <EOL> class Media : <EOL> css = { <EOL> '<STR_LIT:all>' : ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> } <EOL> js = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class MyWidget4 ( TextInput ) : <EOL> def _media ( self ) : <EOL> return Media ( css = { '<STR_LIT:all>' : ( '<STR_LIT>' , ) } , js = ( '<STR_LIT>' , ) ) <EOL> media = property ( _media ) <EOL> class MyWidget9 ( MyWidget4 ) : <EOL> class Media : <EOL> css = { <EOL> '<STR_LIT:all>' : ( '<STR_LIT>' , ) <EOL> } <EOL> js = ( '<STR_LIT>' , ) <EOL> w9 = MyWidget9 ( ) <EOL> self . assertEqual ( str ( w9 . media ) , """<STR_LIT>""" ) <EOL> class MyWidget10 ( MyWidget1 ) : <EOL> class Media : <EOL> extend = False <EOL> css = { <EOL> '<STR_LIT:all>' : ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> } <EOL> js = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> w10 = MyWidget10 ( ) <EOL> self . assertEqual ( str ( w10 . media ) , """<STR_LIT>""" ) <EOL> def test_media_inheritance_extends ( self ) : <EOL> class MyWidget1 ( TextInput ) : <EOL> class Media : <EOL> css = { <EOL> '<STR_LIT:all>' : ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> } <EOL> js = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class MyWidget11 ( MyWidget1 ) : <EOL> class Media : <EOL> extend = True <EOL> css = { <EOL> '<STR_LIT:all>' : ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> } <EOL> js = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> w11 = MyWidget11 ( ) <EOL> self . assertEqual ( str ( w11 . media ) , """<STR_LIT>""" ) <EOL> def test_media_inheritance_single_type ( self ) : <EOL> class MyWidget1 ( TextInput ) : <EOL> class Media : <EOL> css = { <EOL> '<STR_LIT:all>' : ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> } <EOL> js = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class MyWidget12 ( MyWidget1 ) : <EOL> class Media : <EOL> extend = ( '<STR_LIT>' , ) <EOL> css = { <EOL> '<STR_LIT:all>' : ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> } <EOL> js = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> w12 = MyWidget12 ( ) <EOL> self . assertEqual ( str ( w12 . media ) , """<STR_LIT>""" ) <EOL> def test_multi_media ( self ) : <EOL> class MultimediaWidget ( TextInput ) : <EOL> class Media : <EOL> css = { <EOL> '<STR_LIT>' : ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , ) <EOL> } <EOL> js = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> multimedia = MultimediaWidget ( ) <EOL> self . assertEqual ( str ( multimedia . media ) , """<STR_LIT>""" ) <EOL> def test_multi_widget ( self ) : <EOL> class MyWidget1 ( TextInput ) : <EOL> class Media : <EOL> css = { <EOL> '<STR_LIT:all>' : ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> } <EOL> js = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class MyWidget2 ( TextInput ) : <EOL> class Media : <EOL> css = { <EOL> '<STR_LIT:all>' : ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> } <EOL> js = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> class MyWidget3 ( TextInput ) : <EOL> class Media : <EOL> css = { <EOL> '<STR_LIT:all>' : ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> } <EOL> js = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> class MyMultiWidget ( MultiWidget ) : <EOL> def __init__ ( self , attrs = None ) : <EOL> widgets = [ MyWidget1 , MyWidget2 , MyWidget3 ] <EOL> super ( MyMultiWidget , self ) . __init__ ( widgets , attrs ) <EOL> mymulti = MyMultiWidget ( ) <EOL> self . assertEqual ( str ( mymulti . media ) , """<STR_LIT>""" ) <EOL> def test_form_media ( self ) : <EOL> class MyWidget1 ( TextInput ) : <EOL> class Media : <EOL> css = { <EOL> '<STR_LIT:all>' : ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> } <EOL> js = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class MyWidget2 ( TextInput ) : <EOL> class Media : <EOL> css = { <EOL> '<STR_LIT:all>' : ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> } <EOL> js = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> class MyWidget3 ( TextInput ) : <EOL> class Media : <EOL> css = { <EOL> '<STR_LIT:all>' : ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> } <EOL> js = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> class MyForm ( Form ) : <EOL> field1 = CharField ( max_length = <NUM_LIT:20> , widget = MyWidget1 ( ) ) <EOL> field2 = CharField ( max_length = <NUM_LIT:20> , widget = MyWidget2 ( ) ) <EOL> f1 = MyForm ( ) <EOL> self . assertEqual ( str ( f1 . media ) , """<STR_LIT>""" ) <EOL> class AnotherForm ( Form ) : <EOL> field3 = CharField ( max_length = <NUM_LIT:20> , widget = MyWidget3 ( ) ) <EOL> f2 = AnotherForm ( ) <EOL> self . assertEqual ( str ( f1 . media + f2 . media ) , """<STR_LIT>""" ) <EOL> class FormWithMedia ( Form ) : <EOL> field1 = CharField ( max_length = <NUM_LIT:20> , widget = MyWidget1 ( ) ) <EOL> field2 = CharField ( max_length = <NUM_LIT:20> , widget = MyWidget2 ( ) ) <EOL> class Media : <EOL> js = ( '<STR_LIT>' , ) <EOL> css = { <EOL> '<STR_LIT:all>' : ( '<STR_LIT>' , ) <EOL> } <EOL> f3 = FormWithMedia ( ) <EOL> self . assertEqual ( str ( f3 . media ) , """<STR_LIT>""" ) <EOL> self . assertEqual ( Template ( "<STR_LIT>" ) . render ( Context ( { '<STR_LIT>' : f3 } ) ) , """<STR_LIT>""" ) <EOL> @ override_settings ( <EOL> STATIC_URL = '<STR_LIT>' , <EOL> MEDIA_URL = '<STR_LIT>' , <EOL> ) <EOL> class StaticFormsMediaTestCase ( TestCase ) : <EOL> """<STR_LIT>""" <EOL> def test_construction ( self ) : <EOL> m = Media ( css = { '<STR_LIT:all>' : ( '<STR_LIT>' , '<STR_LIT>' ) } , js = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> self . assertEqual ( str ( m ) , """<STR_LIT>""" ) <EOL> class Foo : <EOL> css = { <EOL> '<STR_LIT:all>' : ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> } <EOL> js = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> m3 = Media ( Foo ) <EOL> self . assertEqual ( str ( m3 ) , """<STR_LIT>""" ) <EOL> class MyWidget ( TextInput ) : <EOL> pass <EOL> w = MyWidget ( ) <EOL> self . assertEqual ( str ( w . media ) , '<STR_LIT>' ) <EOL> def test_media_dsl ( self ) : <EOL> class MyWidget1 ( TextInput ) : <EOL> class Media : <EOL> css = { <EOL> '<STR_LIT:all>' : ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> } <EOL> js = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> w1 = MyWidget1 ( ) <EOL> self . assertEqual ( str ( w1 . media ) , """<STR_LIT>""" ) <EOL> self . assertEqual ( str ( w1 . media [ '<STR_LIT>' ] ) , """<STR_LIT>""" ) <EOL> self . assertEqual ( str ( w1 . media [ '<STR_LIT>' ] ) , """<STR_LIT>""" ) <EOL> def test_combine_media ( self ) : <EOL> class MyWidget1 ( TextInput ) : <EOL> class Media : <EOL> css = { <EOL> '<STR_LIT:all>' : ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> } <EOL> js = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class MyWidget2 ( TextInput ) : <EOL> class Media : <EOL> css = { <EOL> '<STR_LIT:all>' : ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> } <EOL> js = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> class MyWidget3 ( TextInput ) : <EOL> class Media : <EOL> css = { <EOL> '<STR_LIT:all>' : ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> } <EOL> js = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> w1 = MyWidget1 ( ) <EOL> w2 = MyWidget2 ( ) <EOL> w3 = MyWidget3 ( ) <EOL> self . assertEqual ( str ( w1 . media + w2 . media + w3 . media ) , """<STR_LIT>""" ) <EOL> self . assertEqual ( str ( w1 . media ) , """<STR_LIT>""" ) <EOL> class MyWidget4 ( TextInput ) : <EOL> class Media : <EOL> css = { '<STR_LIT:all>' : ( '<STR_LIT>' , '<STR_LIT>' ) } <EOL> js = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> w4 = MyWidget4 ( ) <EOL> self . assertEqual ( str ( w4 . media ) , """<STR_LIT>""" ) <EOL> def test_media_property ( self ) : <EOL> class MyWidget4 ( TextInput ) : <EOL> def _media ( self ) : <EOL> return Media ( css = { '<STR_LIT:all>' : ( '<STR_LIT>' , ) } , js = ( '<STR_LIT>' , ) ) <EOL> media = property ( _media ) <EOL> w4 = MyWidget4 ( ) <EOL> self . assertEqual ( str ( w4 . media ) , """<STR_LIT>""" ) <EOL> class MyWidget5 ( MyWidget4 ) : <EOL> def _media ( self ) : <EOL> return super ( MyWidget5 , self ) . media + Media ( css = { '<STR_LIT:all>' : ( '<STR_LIT>' , ) } , js = ( '<STR_LIT>' , ) ) <EOL> media = property ( _media ) <EOL> w5 = MyWidget5 ( ) <EOL> self . assertEqual ( str ( w5 . media ) , """<STR_LIT>""" ) <EOL> def test_media_property_parent_references ( self ) : <EOL> class MyWidget1 ( TextInput ) : <EOL> class Media : <EOL> css = { <EOL> '<STR_LIT:all>' : ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> } <EOL> js = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class MyWidget6 ( MyWidget1 ) : <EOL> def _media ( self ) : <EOL> return super ( MyWidget6 , self ) . media + Media ( css = { '<STR_LIT:all>' : ( '<STR_LIT>' , ) } , js = ( '<STR_LIT>' , ) ) <EOL> media = property ( _media ) <EOL> w6 = MyWidget6 ( ) <EOL> self . assertEqual ( str ( w6 . media ) , """<STR_LIT>""" ) <EOL> def test_media_inheritance ( self ) : <EOL> class MyWidget1 ( TextInput ) : <EOL> class Media : <EOL> css = { <EOL> '<STR_LIT:all>' : ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> } <EOL> js = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class MyWidget7 ( MyWidget1 ) : <EOL> pass <EOL> w7 = MyWidget7 ( ) <EOL> self . assertEqual ( str ( w7 . media ) , """<STR_LIT>""" ) <EOL> class MyWidget8 ( MyWidget1 ) : <EOL> class Media : <EOL> css = { <EOL> '<STR_LIT:all>' : ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> } <EOL> js = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> w8 = MyWidget8 ( ) <EOL> self . assertEqual ( str ( w8 . media ) , """<STR_LIT>""" ) <EOL> def test_media_inheritance_from_property ( self ) : <EOL> class MyWidget1 ( TextInput ) : <EOL> class Media : <EOL> css = { <EOL> '<STR_LIT:all>' : ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> } <EOL> js = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class MyWidget4 ( TextInput ) : <EOL> def _media ( self ) : <EOL> return Media ( css = { '<STR_LIT:all>' : ( '<STR_LIT>' , ) } , js = ( '<STR_LIT>' , ) ) <EOL> media = property ( _media ) <EOL> class MyWidget9 ( MyWidget4 ) : <EOL> class Media : <EOL> css = { <EOL> '<STR_LIT:all>' : ( '<STR_LIT>' , ) <EOL> } <EOL> js = ( '<STR_LIT>' , ) <EOL> w9 = MyWidget9 ( ) <EOL> self . assertEqual ( str ( w9 . media ) , """<STR_LIT>""" ) <EOL> class MyWidget10 ( MyWidget1 ) : <EOL> class Media : <EOL> extend = False <EOL> css = { <EOL> '<STR_LIT:all>' : ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> } <EOL> js = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> w10 = MyWidget10 ( ) <EOL> self . assertEqual ( str ( w10 . media ) , """<STR_LIT>""" ) <EOL> def test_media_inheritance_extends ( self ) : <EOL> class MyWidget1 ( TextInput ) : <EOL> class Media : <EOL> css = { <EOL> '<STR_LIT:all>' : ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> } <EOL> js = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class MyWidget11 ( MyWidget1 ) : <EOL> class Media : <EOL> extend = True <EOL> css = { <EOL> '<STR_LIT:all>' : ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> } <EOL> js = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> w11 = MyWidget11 ( ) <EOL> self . assertEqual ( str ( w11 . media ) , """<STR_LIT>""" ) <EOL> def test_media_inheritance_single_type ( self ) : <EOL> class MyWidget1 ( TextInput ) : <EOL> class Media : <EOL> css = { <EOL> '<STR_LIT:all>' : ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> } <EOL> js = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class MyWidget12 ( MyWidget1 ) : <EOL> class Media : <EOL> extend = ( '<STR_LIT>' , ) <EOL> css = { <EOL> '<STR_LIT:all>' : ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> } <EOL> js = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> w12 = MyWidget12 ( ) <EOL> self . assertEqual ( str ( w12 . media ) , """<STR_LIT>""" ) <EOL> def test_multi_media ( self ) : <EOL> class MultimediaWidget ( TextInput ) : <EOL> class Media : <EOL> css = { <EOL> '<STR_LIT>' : ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , ) <EOL> } <EOL> js = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> multimedia = MultimediaWidget ( ) <EOL> self . assertEqual ( str ( multimedia . media ) , """<STR_LIT>""" ) <EOL> def test_multi_widget ( self ) : <EOL> class MyWidget1 ( TextInput ) : <EOL> class Media : <EOL> css = { <EOL> '<STR_LIT:all>' : ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> } <EOL> js = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class MyWidget2 ( TextInput ) : <EOL> class Media : <EOL> css = { <EOL> '<STR_LIT:all>' : ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> } <EOL> js = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> class MyWidget3 ( TextInput ) : <EOL> class Media : <EOL> css = { <EOL> '<STR_LIT:all>' : ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> } <EOL> js = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> class MyMultiWidget ( MultiWidget ) : <EOL> def __init__ ( self , attrs = None ) : <EOL> widgets = [ MyWidget1 , MyWidget2 , MyWidget3 ] <EOL> super ( MyMultiWidget , self ) . __init__ ( widgets , attrs ) <EOL> mymulti = MyMultiWidget ( ) <EOL> self . assertEqual ( str ( mymulti . media ) , """<STR_LIT>""" ) <EOL> def test_form_media ( self ) : <EOL> class MyWidget1 ( TextInput ) : <EOL> class Media : <EOL> css = { <EOL> '<STR_LIT:all>' : ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> } <EOL> js = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class MyWidget2 ( TextInput ) : <EOL> class Media : <EOL> css = { <EOL> '<STR_LIT:all>' : ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> } <EOL> js = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> class MyWidget3 ( TextInput ) : <EOL> class Media : <EOL> css = { <EOL> '<STR_LIT:all>' : ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> } <EOL> js = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> class MyForm ( Form ) : <EOL> field1 = CharField ( max_length = <NUM_LIT:20> , widget = MyWidget1 ( ) ) <EOL> field2 = CharField ( max_length = <NUM_LIT:20> , widget = MyWidget2 ( ) ) <EOL> f1 = MyForm ( ) <EOL> self . assertEqual ( str ( f1 . media ) , """<STR_LIT>""" ) <EOL> class AnotherForm ( Form ) : <EOL> field3 = CharField ( max_length = <NUM_LIT:20> , widget = MyWidget3 ( ) ) <EOL> f2 = AnotherForm ( ) <EOL> self . assertEqual ( str ( f1 . media + f2 . media ) , """<STR_LIT>""" ) <EOL> class FormWithMedia ( Form ) : <EOL> field1 = CharField ( max_length = <NUM_LIT:20> , widget = MyWidget1 ( ) ) <EOL> field2 = CharField ( max_length = <NUM_LIT:20> , widget = MyWidget2 ( ) ) <EOL> class Media : <EOL> js = ( '<STR_LIT>' , ) <EOL> css = { <EOL> '<STR_LIT:all>' : ( '<STR_LIT>' , ) <EOL> } <EOL> f3 = FormWithMedia ( ) <EOL> self . assertEqual ( str ( f3 . media ) , """<STR_LIT>""" ) <EOL> self . assertEqual ( Template ( "<STR_LIT>" ) . render ( Context ( { '<STR_LIT>' : f3 } ) ) , """<STR_LIT>""" ) </s>
