Ejemplo n.º 1
0
    def test_ask_user(self):
        from kamaki.cli.utils import ask_user
        msg = u'some question'
        out = StringIO()
        user_in = StringIO(u'n')
        self.assertFalse(ask_user(msg, out=out, user_in=user_in))
        self.assertEqual(out.getvalue(), u'%s [y/N]: ' % msg)

        user_in.seek(0)
        out.seek(0)
        self.assertTrue(ask_user(msg, ('n', ), out=out, user_in=user_in))
        self.assertEqual(out.getvalue(), u'%s [n/<not n>]: ' % msg)

        user_in = StringIO(unicode('N'))
        out.seek(0)
        self.assertTrue(ask_user(msg, ('r', 'N'), out=out, user_in=user_in))
        self.assertEqual(out.getvalue(), u'%s [r, N/<not r, N>]: ' % msg)
Ejemplo n.º 2
0
 def ask_user(self, *args, **kwargs):
     kwargs.setdefault('user_in', self._in)
     kwargs.setdefault('out', self)
     return ask_user(*args, **kwargs)
Ejemplo n.º 3
0
 def ask_user(self, *args, **kwargs):
     kwargs.setdefault('user_in', self._in)
     kwargs.setdefault('out', self)
     return ask_user(*args, **kwargs)