def test_pushd_appends_current_dir_to_stack_if_empty():
 mox = Mox()
 old_os = io.os
 io.os = mox.CreateMockAnything()
 class MyFs(io.FileSystem, ):
  stack = []
  @classmethod
  def current_dir(cls):
   return 'should be current dir'
 io.os.chdir('somewhere')
 mox.ReplayAll()
 try:
  assert (len(MyFs.stack) is 0)
  MyFs.pushd('somewhere')
  assert (len(MyFs.stack) is 2)
  assert_equals(MyFs.stack, ['should be current dir', 'somewhere'])
  mox.VerifyAll()
 finally:
  io.os = old_os

def test_pushd_appends_current_dir_to_stack_if_empty ( ) : mox = Mox ( ) old_os = io . os io . os = mox . CreateMockAnything ( ) class MyFs ( io . FileSystem , ) : stack = [ ] @ classmethod def current_dir ( cls ) : return 'should be current dir' io . os . chdir ( 'somewhere' ) mox . ReplayAll ( ) try : assert ( len ( MyFs . stack ) is 0 ) MyFs . pushd ( 'somewhere' ) assert ( len ( MyFs . stack ) is 2 ) assert_equals ( MyFs . stack , [ 'should be current dir' , 'somewhere' ] ) mox . VerifyAll ( ) finally : io . os = old_os
default behaviour of pushd() is adding the current dir to the stack .