def test_block_is_executed_in_a_temporary_directory(self): orig_working_directory = os.getcwd() with m.in_temp_dir(): working_directory_in_block = os.getcwd() self.assertNotEqual(orig_working_directory, working_directory_in_block)
def test_after_block_original_working_directory_is_restored(self): orig_working_directory = os.getcwd() with m.in_temp_dir(): pass self.assertEqual(orig_working_directory, os.getcwd())
def test_cwd(self): wd = os.getcwdu().encode('utf8') with in_temp_dir(): result = m.run(['/bin/sh', '-c', 'pwd'], cwd=wd) self.assertEqual(wd, result.stdout.rstrip())
def _get_external(self): with in_temp_dir(): x = m.working_directory() / 'temporary file' x.content = b'something smallish' yield x
def test_working_directory_is_absolute(self): with in_temp_dir(): x1 = m.working_directory() with in_temp_dir(): x2 = m.working_directory() self.assertNotEqual(x1.path, x2.path)