I think this should have an easy answer and I'm relatively new to Python, so be gentle.
If I have this function:
def random_fruit():
fruits = ['apple','banana','coconut']
return "I like " + random.choice(fruits)
I want to create a test that modifies the fruits list. But I'm can't figure out how to do that. So I want to do something like this, which obviously does not work.
class TestFruit(unittest.TestCase):
@mock.patch('fruits')
def test_random_fruit(self, fruits_list):
fruits_list = ['kiwi']
self.assertEqual(random_fruit(), u"I like kiwi")
Any help would be appreciated. Thanks