79272015

Date: 2024-12-11 14:13:21
Score: 1
Natty:
Report link

I have created the following structure on my filesystem:

project
  |-pb
  |  |-app.py
  |-test_app.py

File app.py:

def run_this_function(something):
    return 'FOLD', {}

def go_to_the_right_street(street_we_are_on):
    if street_we_are_on == 'pre_flop_play':
        action, extra_information = run_this_function('something') <--- added the string definition for 'something' instead something as variable

In this file is present only a modification (see the comment in it).

File test_app.py

import unittest
from unittest.mock import patch
from pb.app import go_to_the_right_street

# I have defined this function to substitute your function run_this_function()
def run_this_function_patch(something):
    return 'FOLD', {}

class MyTestCase(unittest.TestCase):
    def test_go_to_the_right_street(self):
        with patch('pb.app.run_this_function') as mocked_function:
            mocked_function.side_effect = [run_this_function_patch('something')]  # <--- added this side_effect to return 'FOLD', {}
            actual = go_to_the_right_street('pre_flop_play')
            # mocked_function.return_value = 'FOLD', {}  tried this too but I get the same error
            mocked_function.assert_called_once()

if __name__ == '__main__':
    unittest.main()

The 2 most important changes:

Whit this code the output of the execution is the following:

.
----------------------------------------------------------------------
Ran 1 test in 0.001s

OK
Reasons:
  • RegEx Blacklisted phrase (1): I get the same error
  • Long answer (-1):
  • Has code block (-0.5):
  • Me too answer (2.5): I get the same error
  • High reputation (-1):
Posted by: User051209