def activate(self): Mocket.disable() Mocket.enable()
def disable(self): Mocket.disable()
def test_gethostbyname(self): host = socket.gethostbyname('localhost') Mocket.enable() self.assertEqual(socket.gethostbyname('localhost'), '127.0.0.1') Mocket.disable() self.assertEqual(socket.gethostbyname('localhost'), host)
def test_gethostname(self): hostname = socket.gethostname() Mocket.enable() self.assertEqual(socket.gethostname(), 'localhost') Mocket.disable() self.assertEqual(socket.gethostname(), hostname)
def activate(): Mocket.disable() Mocket.enable()
def tearDown(self): # since Player is a singleton object. we need to destroy it # turn off mocket when test is over Mocket.disable()