blob: 4892754b58b538b39657ac943c397eafedadd826 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
from unittest.mock import patch
from organize.actions import Python
from pathlib import Path
def test_print_substitution():
with patch.object(Python, "print") as mock_print:
python = Python("print('Hello World')")
python.run(path=Path.home(), simulate=False)
mock_print.assert_called_with("Hello World")
def test_code_execution():
with patch.object(Python, "print") as mock_print:
path = Path("/some/folder")
python = Python("print(x)\nprint(path)")
python.run(path=path, x=42, simulate=False)
mock_print.assert_any_call(42)
mock_print.assert_any_call(path)
|