'test that pushd works like pushd/popd with built-in cd correctly'

def test_pushd_cd(self):

    import sh
    from sh import mkdir
    child = realpath(tempfile.mkdtemp())
    try:
        old_wd = os.getcwd()
        with sh.pushd(tempdir):
            self.assertEqual(tempdir, os.getcwd())
            sh.cd(child)
            self.assertEqual(child, os.getcwd())
        self.assertEqual(old_wd, os.getcwd())
    finally:
        os.rmdir(child)
