New GitHub issue #118480 from tedmoorman:<br>
<hr>
<pre>
# Bug report
### Bug description:
Thank you for your attention to this bug in the side_effect attribute from the mock module in unittest. Unlike the return_value attribute, side_effect appears to truncate string values down to a single character. This impedes testing of file paths, urls, etc. Please see code below along with results, and please let me know if I can add anything to this issue.
```python
from unittest.mock import MagicMock
def simple_side(arg):
if arg == 1:
return 'here is a string'
if arg == 2:
return 'a string is here too'
mock_return = MagicMock()
mock_return.requests.get.return_value = 'here is a string'
first_return = mock_return.requests.get('something')
print(first_return)
mock_return = MagicMock()
mock_return.requests.get.return_value = 'a string is here too'
second_return = mock_return.requests.get('something')
print(second_return)
mock_side = MagicMock()
mock_side.requests.get.side_effect = simple_side(1)
first_side = mock_side.requests.get('something')
print(first_side)
mock_side.requests.get.side_effect = simple_side(2)
second_side = mock_side.requests.get('something')
print(second_side)
```
results are as follows:
```python
here is a string
a string is here too
h
a
```
### CPython versions tested on:
3.11
### Operating systems tested on:
Windows
</pre>
<hr>
<a href="https://github.com/python/cpython/issues/118480">View on GitHub</a>
<p>Labels: type-bug, stdlib</p>
<p>Assignee: </p>