fork download
  1. #this fixture works
  2. @pytest.fixture
  3. def force_sampler_choice():
  4. with patch('app.sampler.sampler.Random') as mock_random:
  5. yield mock_random.return_value.choices
  6.  
  7.  
  8. #does not works
  9. @pytest.fixture
  10. def force_sampler_choice():
  11. with patch('app.sampler.sampler.Random') as mock_random:
  12. yield mock_random.choices
  13.  
  14.  
  15. def make_random_selection(alist):
  16. r = Random()
  17. return r.choices(a)
  18.  
  19.  
  20. def test_stuff():
  21. force_sampler_choice.side_effect = lambda force_sampler_choice.side_effect = lambda a, *, **_: a[0])
  22. make_random_selection([1,2,3])
  23.  
  24.  
  25.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Traceback (most recent call last):
  File "/usr/lib/python3.7/py_compile.py", line 143, in compile
    _optimize=optimize)
  File "<frozen importlib._bootstrap_external>", line 791, in source_to_code
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "./prog.py", line 17
    return r.choices(a)
                      ^
IndentationError: unindent does not match any outer indentation level

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3.7/py_compile.py", line 147, in compile
    raise py_exc
py_compile.PyCompileError: Sorry: IndentationError: unindent does not match any outer indentation level (prog.py, line 17)
stdout
Standard output is empty