I have subclassed PosixPath this way:
from pathlib import PosixPath
class Node(PosixPath):
def __new__(cls, *args, mykwarg=None, **kwargs):
self = super().__new__(cls, *args, **kwargs)
self._mykwarg = mykwarg
return self
and added several @property methods.
Now if I want to test it (I use pytest), it does not work:
def test_Node(fs):
fs.create_file('simple.txt')
n = Node('simple.txt')
n.stat()
Running the test outputs (at line n.stat()):
E FileNotFoundError: [Errno 2] No such file or directory: 'simple.txt'
what is not completely unexpected, as, I guess, only PosixPath is patched by pyfakefs, but not my own class, even if it inherits from PosixPath.
But I'd liked to be able to test my class while keeping the features of pyfakefs. Have the methods, fields etc. inherited from PosixPath still patched by pyfakefs as is PosixPath, and only have the properties I did add not patched. Is there any way to do that?