<s> import os <EOL> from . . base import BaseTopazTest <EOL> class TestDir ( BaseTopazTest ) : <EOL> def test_name ( self , space ) : <EOL> space . execute ( "<STR_LIT>" ) <EOL> def test_pwd ( self , space ) : <EOL> w_res = space . execute ( "<STR_LIT>" ) <EOL> assert space . str_w ( w_res ) == os . getcwd ( ) <EOL> w_res = space . execute ( "<STR_LIT>" ) <EOL> assert space . str_w ( w_res ) == os . getcwd ( ) <EOL> def test_new ( self , space , tmpdir ) : <EOL> d = tmpdir . mkdir ( "<STR_LIT>" ) <EOL> f = d . join ( "<STR_LIT:content>" ) <EOL> f . write ( "<STR_LIT:hello>" ) <EOL> space . execute ( "<STR_LIT>" % d ) <EOL> with self . raises ( space , "<STR_LIT>" ) : <EOL> space . execute ( "<STR_LIT>" ) <EOL> with self . raises ( space , "<STR_LIT>" ) : <EOL> space . execute ( "<STR_LIT>" % f ) <EOL> def test_delete ( self , space , tmpdir ) : <EOL> d = tmpdir . mkdir ( "<STR_LIT>" ) <EOL> space . execute ( "<STR_LIT>" % d ) <EOL> assert not tmpdir . listdir ( ) <EOL> d = tmpdir . mkdir ( "<STR_LIT>" ) <EOL> f = d . join ( "<STR_LIT:content>" ) <EOL> f . write ( "<STR_LIT:hello>" ) <EOL> with self . raises ( space , "<STR_LIT>" ) : <EOL> space . execute ( "<STR_LIT>" % d ) <EOL> def test_mkdir ( self , space , tmpdir ) : <EOL> space . execute ( "<STR_LIT>" % tmpdir ) <EOL> assert tmpdir . join ( "<STR_LIT>" ) . check ( ) <EOL> assert tmpdir . join ( "<STR_LIT>" ) . stat ( ) . mode & <NUM_LIT:0> <NUM_LIT:100> == <NUM_LIT:0> <NUM_LIT:100> <EOL> def test_chdir ( self , space , tmpdir , monkeypatch ) : <EOL> w_res = space . execute ( """<STR_LIT>""" % tmpdir ) <EOL> paths = [ os . getcwd ( ) , os . path . realpath ( str ( tmpdir ) ) , os . getcwd ( ) ] <EOL> assert self . unwrap ( space , w_res ) == paths <EOL> monkeypatch . setenv ( "<STR_LIT>" , str ( tmpdir ) ) <EOL> w_res = space . execute ( """<STR_LIT>""" ) <EOL> assert space . str_w ( w_res ) == os . path . realpath ( str ( tmpdir ) ) <EOL> def test_glob ( self , space , tmpdir ) : <EOL> sub1 = tmpdir . mkdir ( "<STR_LIT>" ) <EOL> sub2 = tmpdir . mkdir ( "<STR_LIT>" ) <EOL> sub1 . join ( "<STR_LIT>" ) . ensure ( ) <EOL> sub1 . join ( "<STR_LIT>" ) . ensure ( ) <EOL> sub2 . join ( "<STR_LIT>" ) . ensure ( ) <EOL> sub2 . join ( "<STR_LIT>" ) . ensure ( ) <EOL> w_res = space . execute ( """<STR_LIT>""" % tmpdir ) <EOL> res = self . unwrap ( space , w_res ) <EOL> res . sort ( ) <EOL> assert res == [ "<STR_LIT>" , "<STR_LIT>" ] <EOL> w_res = space . execute ( """<STR_LIT>""" % tmpdir ) <EOL> res = self . unwrap ( space , w_res ) <EOL> res . sort ( ) <EOL> assert res == [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> w_res = space . execute ( """<STR_LIT>""" % tmpdir ) <EOL> res = self . unwrap ( space , w_res ) <EOL> res . sort ( ) <EOL> assert res == [ "<STR_LIT>" , "<STR_LIT>" ] <EOL> w_res = space . execute ( """<STR_LIT>""" % tmpdir ) <EOL> res = self . unwrap ( space , w_res ) <EOL> res . sort ( ) <EOL> assert res == [ "<STR_LIT>" , "<STR_LIT>" ] <EOL> w_res = space . execute ( """<STR_LIT>""" % ( tmpdir , tmpdir . join ( "<STR_LIT:..>" ) ) ) <EOL> assert self . unwrap ( space , w_res ) == [ str ( tmpdir . join ( "<STR_LIT:..>" ) ) + "<STR_LIT:/>" ] <EOL> w_res = space . execute ( """<STR_LIT>""" % tmpdir ) <EOL> res = self . unwrap ( space , w_res ) <EOL> assert res == [ [ "<STR_LIT>" ] , [ "<STR_LIT>" ] ] <EOL> def test_read ( self , space , tmpdir ) : <EOL> d = tmpdir . mkdir ( "<STR_LIT>" ) <EOL> f = d . join ( "<STR_LIT:content>" ) <EOL> f . write ( "<STR_LIT:hello>" ) <EOL> f = d . join ( "<STR_LIT>" ) <EOL> f . write ( "<STR_LIT:hello>" ) <EOL> w_res = space . execute ( """<STR_LIT>""" % d ) <EOL> res = self . unwrap ( space , w_res ) <EOL> res . sort ( ) <EOL> assert res == [ None , "<STR_LIT:.>" , "<STR_LIT:..>" , "<STR_LIT:content>" , "<STR_LIT>" ] <EOL> def test_close ( self , space , tmpdir ) : <EOL> with self . raises ( space , "<STR_LIT>" , "<STR_LIT>" ) : <EOL> space . execute ( """<STR_LIT>""" % tmpdir ) <EOL> with self . raises ( space , "<STR_LIT>" , "<STR_LIT>" ) : <EOL> space . execute ( """<STR_LIT>""" % tmpdir ) </s>
