Mock a raw_input


I have the following functions with raw input, which should receive a list [x, y]

def input_origem():
    origem = raw_input("Entre com o valor de x: ")
    origem = eval(origem)
    return origem

def input_saida():
    destino = raw_input("Entre com o valor de y  ")
    destino = eval(destino)
    return destino

def my func(origem, destino):


print  myfunc(input_origem(), input_saida())

Until then, it works fine, but I do not know how to mock it.

I was trying as follows:

class TEste(base.TestCase):
    def test_movimento_cavalo(self, origem_mock, saida_mock):
        origem_mock = self.mock.MagicMock()
        saida_mock = self.mock.MagickMock()
        myfunc(origem_mock, saida_mock)[1,1])

He keeps thinking, and when I cancel he rtorna:


source = raw_input ("Enter the value of x:")   KeyboardInterrupt

asked by anonymous 22.12.2016 / 00:26

0 answers