sessions.py
Code: Select all
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()
Code: Select all
@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)
Code: Select all
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)
Andererseits habe ich versucht, touch zu patchen< /code> mit mit, aber der Test besteht auch nicht. Ich kann nicht sagen, ob dieses Problem mit meinem Code oder meinem Test zusammenhängt, daher möchte ich die Community um Hinweise bitten. Was mache ich falsch? Was übersehe ich?