from dask.utils import textblock
from dask.utils import filetext
import os

def test_textblock():
    text = '123 456 789 abc def ghi'.replace(' ', os.linesep)
    with filetext(text) as fn:
        with open(fn, 'rb') as f:
            text = textblock(f, 1, 10)
            assert text == '456 789 '.replace(' ', os.linesep)
            assert set(map(len, text.split())) == set([3])

            assert textblock(f, 1, 10) == textblock(fn, 1, 10)

            assert textblock(f, 0, 3) == '123' + os.linesep
            assert textblock(f, 3 + len(os.linesep), 6) == '456' + os.linesep

@@ -102,16 +102,17 @@
  text = 
+b
 '123 456
@@ -129,32 +129,33 @@
 ef ghi'.replace(
+b
 ' ', os.linesep)
@@ -149,24 +149,33 @@
 , os.linesep
+.encode()
 )%0A    with f
@@ -186,16 +186,27 @@
 ext(text
+, mode='wb'
 ) as fn:
@@ -276,17 +276,17 @@
 (f, 1, 1
-0
+1
 )%0A      
@@ -302,24 +302,25 @@
 ert text == 
+(
 '456 789 '.r
@@ -342,16 +342,26 @@
 linesep)
+).encode()
 %0A       
@@ -518,16 +518,17 @@
 , 3) == 
+(
 '123' + 
@@ -537,16 +537,26 @@
 .linesep
+).encode()
 %0A       
@@ -607,16 +607,17 @@
 , 6) == 
+(
 '456' + 
@@ -626,9 +626,19 @@
 .linesep
+).encode()
 %0A

make textblock windows and py34 safe