from unittest import TestCase
from unittest.mock import patch, Mock
from foo import FooModule
class DemoTest(TestCase):
@classmethod
def setUpClass(cls):
patch("foo.client.Client").start()
def test_craft_message(self):
c = FooModule(0)
c.ping()
@classmethod
def tearDownClass(cls):
patch.stopall()
from .client import Client
class FooModule:
v = -1
def __init__(self, n):
self.v = n
self.client = Client(self)
def ping(self):
self.client.ping(2048)
class Client:
def __init__(self, foo_module):
self.foo = foo_module
def ping(self, n):
return n / self.foo.v