sessions.py
Код: Выделить всё
def generate_folders(paths: list):
for p in paths:
p.mkdir()
Path(p / "output").mkdir()
Path(p / "output" / "output_file").touch()
Path(p / "session_file").touch()
Код: Выделить всё
@patch("os.mkdir")
@patch("pathlib.Path.touch")
def test_folder_creation(self, touch_mock, mkdir_mock):
tags = ["concepts", "models", "animations", "vfx", "sfx", "vo", "music"]
paths = sessions.generate_paths(category="character", name="player", tags=tags)
sessions.generate_folders(paths)
for p in paths:
mkdir_mock.assert_any_call(p, 511)
mkdir_mock.assert_any_call(p / "output", 511)
touch_mock.assert_any_call(Path(p / "output" / "output_file"), 511)
touch_mock.assert_any_call(Path(p / "session_file"), 511)
Код: Выделить всё
ssF...
======================================================================
FAIL: test_folder_creation (sessions.tests.sessions_tests.TestSessionsCreation.test_folder_creation)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Users\juank\AppData\Local\Programs\Python\Python313\Lib\unittest\mock.py", line 1424, in patched
return func(*newargs, **newkeywargs)
File "C:\Users\juank\dev\projects\python\gamedev_eco\sessions\tests\sessions_tests.py", line 51, in test_folder_creation
touch_mock.assert_any_call(Path(p / "output" / "output_file"), 511)
~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\juank\AppData\Local\Programs\Python\Python313\Lib\unittest\mock.py", line 1048, in assert_any_call
raise AssertionError(
'%s call not found' % expected_string
) from cause
AssertionError: touch(WindowsPath('C:/Users/juank/dev/projects/python/gamedev_eco/sessions/character/player/concepts/output/output_file'), 511) call not found
----------------------------------------------------------------------
Ran 6 tests in 0.004s
FAILED (failures=1, skipped=2)
С другой стороны, я попробовал исправить touch< /code> с помощью, но тест тоже не проходит. Я не могу сказать, связана ли эта проблема с моим кодом или с моим тестом, поэтому я хотел бы попросить сообщество дать подсказку. Что я делаю неправильно? Что мне не хватает?
Подробнее здесь: https://stackoverflow.com/questions/793 ... find-calls
Мобильная версия