def test_polyfill(self): class OsPath(object): def __init__(self): for i in ('isabs', 'normpath', 'realpath', 'expanduser'): setattr(self, i, getattr(os.path, i)) with mock.patch('os.path', OsPath()): self.assertEqual( path.samefile(path.Path('/foo/bar'), path.Path('/foo/bar')), True)
def test_real(self): with mock.patch('os.path.samefile', lambda x, y: x == y, create=True): self.assertEqual( path.samefile(path.Path('/foo/bar'), path.Path('/foo/bar')), True)