def test_setup_class_install_environment_predefined_no_dir(self):
from calmjs.cli import PackageManagerDriver
from calmjs import cli
utils.stub_os_environ(self)
utils.stub_mod_call(self, cli)
cwd = mkdtemp(self)
# we have the mock_tempfile context...
self.assertEqual(self.mock_tempfile.count, 1)
os.chdir(cwd)
# a very common use case
os.environ['CALMJS_TEST_ENV'] = '.'
TestCase = type('TestCase', (unittest.TestCase,), {})
# the directory not there.
with self.assertRaises(unittest.SkipTest):
utils.setup_class_install_environment(
TestCase, PackageManagerDriver, [])
# temporary directory should not be created as the skip will
# also stop the teardown from running
self.assertEqual(self.mock_tempfile.count, 1)
# this is still set, but irrelevant.
self.assertEqual(TestCase._env_root, cwd)
# tmpdir not set.
self.assertFalse(hasattr(TestCase, '_cls_tmpdir'))
评论列表
文章目录