def test_stub_apis(self): """Test stub APIs that subclasses should override.""" ins = UI() self.assertEqual("subcommand --foo\nsubcommand --bar", ins.fill_usage("subcommand", ["--foo", "--bar"])) self.assertRaises(NotImplementedError, ins.fill_examples, [("foo", "bar"), ("baz", "bat")])
def test_apis_with_force(self): """Test confirm(), confirm_or_die(), etc. with --force.""" ins = UI(force=True) self.assertTrue(ins.confirm("prompt")) ins.confirm_or_die("prompt") ins.default_confirm_response = False # With --force, the default_confirm_response doesn't apply self.assertTrue(ins.confirm("prompt")) ins.confirm_or_die("prompt") self.assertEqual("hello", ins.get_input("Prompt:", "hello")) self.assertEqual("passwd", ins.get_password("user", "host"))
def test_apis_without_force(self): """Test confirm(), confirm_or_die(), etc. without --force.""" ins = UI() self.assertTrue(ins.confirm("prompt")) ins.confirm_or_die("prompt") ins.default_confirm_response = False self.assertFalse(ins.confirm("prompt")) self.assertRaises(SystemExit, ins.confirm_or_die, "prompt") self.assertEqual("hello", ins.get_input("Prompt:", "hello")) self.assertEqual("passwd", ins.get_password("user", "host"))