Did I find the right examples for you? yes no

All Samples(106)  |  Call(104)  |  Derive(0)  |  Import(2)

        def tob(data, enc='utf8'): # Convert strings to bytes (py2 and py3)
    return data.encode(enc) if isinstance(data, unicode) else data
        


src/m/u/multipart-0.1/test/test_multipart.py   multipart(Download)
# -*- coding: utf-8 -*-
import unittest
import sys, os.path, tempfile
import multipart as mp
from multipart import tob
    def test_line_parser(self):
        for line in ('foo',''):
            for ending in ('\n','\r','\r\n'):
                i = mp.MultipartParser(BytesIO(tob(line+ending)), 'foo')
                i = i._lineiter().next()
                self.assertEqual(i, (tob(line), tob(ending)))
 
    def test_iterlines(self):
        data = 'abc\ndef\r\nghi'
        result = [(tob('abc'),tob('\n')),(tob('def'),tob('\r\n')),(tob('ghi'),tob(''))]

src/m/u/multipart-HEAD/test/test_multipart.py   multipart(Download)
# -*- coding: utf-8 -*-
import unittest
import sys, os.path, tempfile
import multipart as mp
from multipart import tob
    def test_line_parser(self):
        for line in ('foo',''):
            for ending in ('\n','\r','\r\n'):
                i = mp.MultipartParser(BytesIO(tob(line+ending)), 'foo')
                i = i._lineiter().next()
                self.assertEqual(i, (tob(line), tob(ending)))
 
    def test_iterlines(self):
        data = 'abc\ndef\r\nghi'
        result = [(tob('abc'),tob('\n')),(tob('def'),tob('\r\n')),(tob('ghi'),tob(''))]