Beim Erstellen von Scheinordnern mit Pyfakefs ist ein Fehler aufgetretenPython

Python-Programme
Guest
 Beim Erstellen von Scheinordnern mit Pyfakefs ist ein Fehler aufgetreten

Post by Guest »

Ich arbeite an einem Projekt, das Pyfakefs verwendet, um mein Dateisystem zu verspotten, um die Ordnererstellung und fehlende Ordner in einer zuvor definierten Baumstruktur zu testen. Ich verwende Python 3.13 unter Windows und erhalte diese Ausgabe vom Terminal, nachdem ich meinen Test ausgeführt habe:
Terminalausgabe :
(Hat jemand einen Tipp zum Formatieren der Terminalausgabe ohne automatische Syntaxhervorhebung?)

Code: Select all

E
======================================================================
ERROR: test_top_folders_exist (file_checker.tests.file_checker_tests.TestFolderCheck.test_top_folders_exist)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Users\juank\dev\projects\python\gamedev_eco\file_checker\tests\file_checker_tests.py", line 20, in test_top_folders_exist
self.fs.create_dir(Path.cwd() / "gdd")
~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
File "C:\Users\juank\AppData\Local\Programs\Python\Python313\Lib\site-packages\pyfakefs\fake_filesystem.py", line 2191, in create_dir
dir_path = self.absnormpath(dir_path)
File "C:\Users\juank\AppData\Local\Programs\Python\Python313\Lib\site-packages\pyfakefs\fake_filesystem.py", line 1133, in absnormpath
path = self.replace_windows_root(path)
File "C:\Users\juank\AppData\Local\Programs\Python\Python313\Lib\site-packages\pyfakefs\fake_filesystem.py", line 1418, in replace_windows_root
if path and self.is_windows_fs and self.root_dir:
^^^^^^^^^^^^^
File "C:\Users\juank\AppData\Local\Programs\Python\Python313\Lib\site-packages\pyfakefs\fake_filesystem.py", line 357, in root_dir
return self._mount_point_dir_for_cwd()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "C:\Users\juank\AppData\Local\Programs\Python\Python313\Lib\site-packages\pyfakefs\fake_filesystem.py", line 631, in _mount_point_dir_for_cwd
if path.startswith(str_root_path) and len(str_root_path) > len(mount_path):
^^^^^^^^^^^^^^^
AttributeError: 'WindowsPath' object has no attribute 'startswith'

----------------------------------------------------------------------
Ran 1 test in 0.011s

FAILED (errors=1)
Test:

Code: Select all

from pyfakefs.fake_filesystem_unittest import TestCase

class TestFolderCheck(TestCase):
"""Test top folders = gdd marketing business"""

@classmethod
def setUp(cls):
cls.setUpClassPyfakefs()
cls.fake_fs().create_dir(Path.cwd() / "gamedev_eco")
cls.fake_fs().cwd = Path.cwd() / "gamedev_eco"

def test_top_folders_exist(self):
self.fs.create_dir(Path.cwd() / "gdd")
Was mich verwirrt, ist, dass die Setup-Klassenmethode einen Ordner erstellen und cwd in diesen neuen Ordner ändern kann, ich aber keinen Ordner innerhalb eines Tests erstellen kann.
Hat jemand Erfahrung mit Pyfakefs?
Kann mir bitte jemand bei diesem Problem behilflich sein?

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post