Praca domowa
capsys
służy do przychwytywania standardowego wejścia, wyjścia więc jego wynikiem będzie napis, a nie lista. (-1)
próba uruchomienia testów kończy się błędem. Nie widze również żadnych komentarzy pokazujacych świadomość problemu (-4):
╰─$ pytest .
============================================================ test session starts =============================================================
platform linux -- Python 3.8.3, pytest-5.4.3, py-1.9.0, pluggy-0.13.1
rootdir: /home/czaki/Dokumenty/NYPD_2021z/prac_dom/project-1.00011
plugins: napari-plugin-engine-0.1.9
collected 2 items
test_hmw.py .F [100%]
================================================================== FAILURES ==================================================================
_______________________________________________________________ test_calculate _______________________________________________________________
capsys = <_pytest.capture.CaptureFixture object at 0x7f6e37784b20>, monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f6e37784910>
tmpdir = local('/tmp/pytest-of-czaki/pytest-1/test_calculate0')
def test_calculate(capsys, monkeypatch,tmpdir):
def mock_take_from_list(a,b):
return 5
monkeypatch.setattr(hmw,'take_from_list',mock_take_from_list)
f1 = tmpdir.mkdir("sub").join("f1.txt")
f2=tmpdir.join("f2.txt")
f1.write = {"list": [1,2,3,4,5], "indices": 4}
> hmw.calculate(f1,f2)
test_hmw.py:27:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
in_file = local('/tmp/pytest-of-czaki/pytest-1/test_calculate0/sub/f1.txt')
out_file = local('/tmp/pytest-of-czaki/pytest-1/test_calculate0/f2.txt')
def calculate(in_file: str, out_file: str):
> with open(in_file, 'r') as f_p:
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pytest-of-czaki/pytest-1/test_calculate0/sub/f1.txt'
homework.py:28: FileNotFoundError
========================================================== short test summary info ===========================================================
FAILED test_hmw.py::test_calculate - FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pytest-of-czaki/pytest-1/test_calculate0...
======================================================== 1 failed, 1 passed in 0.07s =================================================== /0,5s