Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __new__(cls, *args, **kwargs):
"""Creates the correct subclass based on OS."""
if cls is FakePathlibModule.Path:
cls = (FakePathlibModule.WindowsPath if os.name == 'nt'
else FakePathlibModule.PosixPath)
self = cls._from_parts(args, init=True)
return self
def init_module(filesystem):
"""Initializes the fake module with the fake file system."""
# pylint: disable=protected-access
FakePath.filesystem = filesystem
FakePathlibModule.PureWindowsPath._flavour = _FakeWindowsFlavour(
filesystem)
FakePathlibModule.PurePosixPath._flavour = _FakePosixFlavour(filesystem)
def __new__(cls, *args, **kwargs):
"""Creates the correct subclass based on OS."""
if cls is FakePathlibModule.Path:
cls = (FakePathlibModule.WindowsPath if os.name == 'nt'
else FakePathlibModule.PosixPath)
self = cls._from_parts(args, init=True)
return self
def __init__(self, filesystem):
if self.fake_pathlib is None:
self.__class__.fake_pathlib = FakePathlibModule(filesystem)
def __new__(cls, *args, **kwargs):
"""Creates the correct subclass based on OS."""
if cls is FakePathlibModule.Path:
cls = (FakePathlibModule.WindowsPath if os.name == 'nt'
else FakePathlibModule.PosixPath)
self = cls._from_parts(args, init=True)
return self
def init_module(filesystem):
"""Initializes the fake module with the fake file system."""
# pylint: disable=protected-access
FakePath.filesystem = filesystem
FakePathlibModule.PureWindowsPath._flavour = _FakeWindowsFlavour(
filesystem)
FakePathlibModule.PurePosixPath._flavour = _FakePosixFlavour(filesystem)