2
2
from shelljob import fs, proc
4
with fs.NamedTempFile() as nm:
12
assert f.read() == "Hello"
14
assert not os.path.exists(name)
16
with fs.NamedTempFile( prefix = 'PRE', suffix = '.END' ) as nm:
17
assert nm.find( 'PRE' ) > 0 # can't be first due to directory
18
assert nm.endswith( '.END' )
20
assert not os.path.exists(name)
22
# ensure deleted on exception
24
with fs.NamedTempFile as nm:
26
raise Exception("oops")
28
assert not os.path.exists(name)
31
with fs.NamedTempFile() as nm:
32
proc.call( "curl http://mortoray.com/ -o {}".format( nm ) )
33
html = open(nm,'r').read()
37
assert not os.path.exists(name)
5
with fs.NamedTempFile() as nm:
13
assert f.read() == "Hello"
15
assert not os.path.exists(name)
18
with fs.NamedTempFile( prefix = 'PRE', suffix = '.END' ) as nm:
19
assert nm.find( 'PRE' ) > 0 # can't be first due to directory
20
assert nm.endswith( '.END' )
22
assert not os.path.exists(name)
25
# ensure deleted on exception
27
with fs.NamedTempFile() as nm:
29
raise Exception("oops")
31
assert not os.path.exists(name)
35
with fs.NamedTempFile() as nm:
36
proc.call( "curl http://mortoray.com/ -o {}".format( nm ) )
37
html = open(nm,'r').read()
41
assert not os.path.exists(name)