Test uploading files flask with python 2 and 3 -


firstly question similar one.

but problem of trying write tests require uploading files app can run either in python 2.7 or 3.4.

with following code, when run under python 3.4 error. not sure if matters, running unittests py.test

self.client = app.test_client() open(standard_test_path, 'rb') dataset:         params = {}         params['priority'] = 5         params['dataset'] = (dataset, standard_mol_file)         response = self.client.post(             '/datasets',             data=params         ) 

the error following:

response = self.client.post(             '/datasets',            data=params         )  _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /users/user/.virtualenvs/playground3/lib/python3.4/site-packages/werkzeug/test.py:788: in post     return self.open(*args, **kw) /users/user/.virtualenvs/playground3/lib/python3.4/site-packages/flask/testing.py:108: in open     follow_redirects=follow_redirects) /users/user/.virtualenvs/playground3/lib/python3.4/site-packages/werkzeug/test.py:741: in open     environ = args[0].get_environ() /users/user/.virtualenvs/playground3/lib/python3.4/site-packages/werkzeug/test.py:543: in get_environ     stream_encode_multipart(values, charset=self.charset) /users/user/.virtualenvs/playground3/lib/python3.4/site-packages/werkzeug/test.py:105: in stream_encode_multipart     write_binary(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _  string = 'true'      def write_binary(string):         stream, total_length, on_disk = _closure         if on_disk:             stream.write(string)         else:             length = len(string)             if length + _closure[1] <= threshold: >               stream.write(string) e               typeerror: 'str' not support buffer interface  /users/user/.virtualenvs/playground3/lib/python3.4/site-packages/werkzeug/test.py:59: typeerror 

any on great.


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -