cubicweb/web/test/unittest_web.py
changeset 11156 36252a0c76ec
parent 11155 3bc47295c262
child 11157 42fa15632493
equal deleted inserted replaced
11155:3bc47295c262 11156:36252a0c76ec
    70 
    70 
    71     def _fobject(self, fname):
    71     def _fobject(self, fname):
    72         return open(join(self.datadir, fname), 'rb')
    72         return open(join(self.datadir, fname), 'rb')
    73 
    73 
    74     def _fcontent(self, fname):
    74     def _fcontent(self, fname):
    75         return self._fobject(fname).read()
    75         with self._fobject(fname) as f:
       
    76             return f.read()
    76 
    77 
    77     def test_single_file_upload(self):
    78     def test_single_file_upload(self):
    78         files = {'file': ('schema.py', self._fobject('schema.py'))}
    79         files = {'file': ('schema.py', self._fobject('schema.py'))}
    79         webreq = requests.post(self._post_url, files=files)
    80         webreq = requests.post(self._post_url, files=files)
    80         # check backward compat : a single uploaded file leads to a single
    81         # check backward compat : a single uploaded file leads to a single