Hello,
I'm not sure of what you want to do, but you can create a file-like
object (with read and readlines method) using StringIO objects.
This class is defined in the StringIO module for Python 2.7 and io
module for Python 3.X. Here's an example using Python 3:
>>> stream = io.StringIO("that works")
>>> stream.read()
'that works'
>>>
Hope that helps,
Vincent
2013/5/6, Tyrone Schiff <
sch...@google.com>:
> Hi there,
> I'm trying to write a unit test to verify that I've uploaded a file
> correctly via CherryPy. According to the CherryPy
> docs<
http://docs.cherrypy.org/stable/progguide/files/uploading.html>,
> I access the uploaded attachment like this:
>
> attachment.file.read()
>
> Does anyone have any familiarity writing unit tests for file objects?
>
> Thank you!
>
> --
> You received this message because you are subscribed to the Google Groups
> "cherrypy-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
cherrypy-user...@googlegroups.com.
> To post to this group, send email to
cherryp...@googlegroups.com.
> Visit this group at
http://groups.google.com/group/cherrypy-users?hl=en.
> For more options, visit
https://groups.google.com/groups/opt_out.
>
>
>