from hdfs3 import HDFileSystem

def test_example():
    import time
    
    fs = HDFileSystem(host='localhost', port=8020)
    print(fs)

    data = b'a' * (10 * 2**20)

    with fs.open('/tmp/test', 'w', repl=1) as f:
        t0 = time.time()
        f.write(data)
    t1 = time.time()
    print(t1 - t0)

    with fs.open('/tmp/test', 'r') as f:
        out = f.read(len(data))
        assert len(data) == len(out)
        assert out == data
    print(time.time() - t1)

@@ -28,54 +28,64 @@
 tem%0A
-%0Adef test_example():%0A    import time%0A    
+import pytest%0A%0A%0A@pytest.yield_fixture%0Adef hdfs():
 %0A    
+hd
 fs =
@@ -135,18 +135,190 @@
     
-print(fs)%0A
+if hdfs.ls('/tmp/test'):%0A        hdfs.rm('/tmp/test')%0A    hdfs.mkdir('/tmp/test')%0A%0A    yield hdfs%0A%0A    if hdfs.ls('/tmp/test'):%0A        hdfs.rm('/tmp/test')%0A%0A%0Adef test_example(hdfs):
 %0A   
@@ -347,32 +347,34 @@
 **20)%0A%0A    with 
+hd
 fs.open('/tmp/te
@@ -371,24 +371,29 @@
 n('/tmp/test
+/file
 ', 'w', repl
@@ -414,85 +414,20 @@
     
-t0 = time.time()%0A        f.write(data)%0A    t1 = time.time()%0A    print(t1 - t0
+f.write(data
 )%0A%0A 
@@ -434,16 +434,18 @@
    with 
+hd
 fs.open(
@@ -454,16 +454,21 @@
 tmp/test
+/file
 ', 'r') 
@@ -573,32 +573,411 @@
 ata%0A
-    print(time.time() - t1
+%0A%0Adef test_ls_touch(hdfs):%0A    assert not hdfs.ls('/tmp/test')%0A    hdfs.touch('/tmp/test/1')%0A    hdfs.touch('/tmp/test/2')%0A    L = hdfs.ls('/tmp/test')%0A    assert set(d%5B'name'%5D for d in L) == %7B'/tmp/test/1', '/tmp/test/2'%7D%0A%0A%0Adef test_rm(hdfs):%0A    assert not hdfs.ls('/tmp/test')%0A    hdfs.touch('/tmp/test/1')%0A    assert hdfs.ls('/tmp/test/1')%0A    hdfs.rm('/tmp/test/1')%0A    assert not hdfs.ls('/tmp/test'
 )%0A

create pytest fixture for hdfs