MCPcopy Index your code
hub / github.com/python/cpython / test_make_archive_cwd

Method test_make_archive_cwd

Lib/test/test_shutil.py:1986–2007  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1984 unregister_archive_format('xxx')
1985
1986 def test_make_archive_cwd(self):
1987 current_dir = os.getcwd()
1988 root_dir = self.mkdtemp()
1989 def archiver(base_name, base_dir, **kw):
1990 self.assertNotIn('root_dir', kw)
1991 self.assertEqual(base_name, os.path.join(current_dir, 'basename'))
1992 self.assertEqual(os.getcwd(), root_dir)
1993 raise RuntimeError()
1994 dirs = []
1995 def _chdir(path):
1996 dirs.append(path)
1997 orig_chdir(path)
1998
1999 register_archive_format('xxx', archiver, [], 'xxx file')
2000 try:
2001 with support.swap_attr(os, 'chdir', _chdir) as orig_chdir:
2002 with self.assertRaises(RuntimeError):
2003 make_archive('basename', 'xxx', root_dir=root_dir)
2004 self.assertEqual(os.getcwd(), current_dir)
2005 self.assertEqual(dirs, [root_dir, current_dir])
2006 finally:
2007 unregister_archive_format('xxx')
2008
2009 def test_make_archive_cwd_supports_root_dir(self):
2010 current_dir = os.getcwd()

Callers

nothing calls this directly

Calls 6

register_archive_formatFunction · 0.90
make_archiveFunction · 0.90
mkdtempMethod · 0.80
assertRaisesMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected