@@ -101,49 +101,46 @@ def article(article_content):
101101
102102
103103def test_write_article (tmpdir , article ):
104- zim_creator = ZimCreator (
105- str (tmpdir / "test.zim" ),
104+ with ZimCreator (
105+ str (tmpdir / "test.zim" ),
106106 main_page = "welcome" ,
107107 index_language = "eng" ,
108- min_chunk_size = 2048
109- )
110- zim_creator .add_article (article )
111- zim_creator .update_metadata (
112- creator = 'python-libzim' ,
113- description = 'Created in python' ,
114- name = 'Hola' ,
115- publisher = 'Monadical' ,
116- title = 'Test Zim'
117- )
118- zim_creator .close ()
108+ min_chunk_size = 2048 ,
109+ ) as zim_creator :
110+ zim_creator .add_article (article )
111+ zim_creator .update_metadata (
112+ creator = "python-libzim" ,
113+ description = "Created in python" ,
114+ name = "Hola" ,
115+ publisher = "Monadical" ,
116+ title = "Test Zim" ,
117+ )
119118
120119
121120def test_article_metadata (tmpdir , metadata ):
122- zim_creator = ZimCreator (
123- str (tmpdir / "test.zim" ),
124- main_page = "welcome" ,
125- index_language = "eng" ,
126- min_chunk_size = 2048
127- )
128- zim_creator .update_metadata (** metadata )
129- assert zim_creator ._metadata == metadata
130- zim_creator .close ()
121+ with ZimCreator (
122+ str (tmpdir / "test.zim" ),
123+ main_page = "welcome" ,
124+ index_language = "eng" ,
125+ min_chunk_size = 2048 ,
126+ ) as zim_creator :
127+ zim_creator .update_metadata (** metadata )
128+ assert zim_creator ._metadata == metadata
131129
132130
133131def test_check_mandatory_metadata (tmpdir ):
134- zim_creator = ZimCreator (
135- str (tmpdir / "test.zim" ),
136- main_page = "welcome" ,
137- index_language = "eng" ,
138- min_chunk_size = 2048
139- )
140- assert not zim_creator .mandatory_metadata_ok ()
141- zim_creator .update_metadata (
142- creator = 'python-libzim' ,
143- description = 'Created in python' ,
144- name = 'Hola' ,
145- publisher = 'Monadical' ,
146- title = 'Test Zim'
147- )
148- assert zim_creator .mandatory_metadata_ok ()
149- zim_creator .close ()
132+ with ZimCreator (
133+ str (tmpdir / "test.zim" ),
134+ main_page = "welcome" ,
135+ index_language = "eng" ,
136+ min_chunk_size = 2048 ,
137+ ) as zim_creator :
138+ assert not zim_creator .mandatory_metadata_ok ()
139+ zim_creator .update_metadata (
140+ creator = "python-libzim" ,
141+ description = "Created in python" ,
142+ name = "Hola" ,
143+ publisher = "Monadical" ,
144+ title = "Test Zim" ,
145+ )
146+ assert zim_creator .mandatory_metadata_ok ()
0 commit comments