47
47
from pyfakefs .fake_filesystem import FakeFilesystem
48
48
from pyfakefs .fake_open import fake_open
49
49
from pyfakefs .fake_os import FakeOsModule , use_original_os
50
- from pyfakefs .helpers import IS_PYPY
50
+ from pyfakefs .helpers import IS_PYPY , is_called_from_skipped_module
51
51
52
52
53
53
def init_module (filesystem ):
@@ -92,6 +92,18 @@ def init_module(filesystem):
92
92
def _wrap_strfunc (strfunc ):
93
93
@functools .wraps (strfunc )
94
94
def _wrapped (pathobj , * args , ** kwargs ):
95
+ should_use_original = False
96
+ if pathobj .filesystem .patcher :
97
+ skip_names = pathobj .filesystem .patcher ._skip_names
98
+ if is_called_from_skipped_module (skip_names = skip_names ):
99
+ should_use_original = True
100
+
101
+ if should_use_original :
102
+ return getattr (pathobj ._original_accessor , strfunc .__name__ )(
103
+ str (pathobj ),
104
+ * args ,
105
+ ** kwargs ,
106
+ )
95
107
return strfunc (pathobj .filesystem , str (pathobj ), * args , ** kwargs )
96
108
97
109
return staticmethod (_wrapped )
@@ -100,6 +112,18 @@ def _wrapped(pathobj, *args, **kwargs):
100
112
def _wrap_binary_strfunc (strfunc ):
101
113
@functools .wraps (strfunc )
102
114
def _wrapped (pathobj1 , pathobj2 , * args ):
115
+ should_use_original = False
116
+ if pathobj1 .filesystem .patcher :
117
+ skip_names = pathobj1 .filesystem .patcher ._skip_names
118
+ if is_called_from_skipped_module (skip_names = skip_names ):
119
+ should_use_original = True
120
+
121
+ if should_use_original :
122
+ return getattr (pathobj1 ._original_accessor , strfunc .__name__ )(
123
+ str (pathobj1 ),
124
+ str (pathobj2 ),
125
+ * args ,
126
+ )
103
127
return strfunc (pathobj1 .filesystem , str (pathobj1 ), str (pathobj2 ), * args )
104
128
105
129
return staticmethod (_wrapped )
@@ -108,6 +132,18 @@ def _wrapped(pathobj1, pathobj2, *args):
108
132
def _wrap_binary_strfunc_reverse (strfunc ):
109
133
@functools .wraps (strfunc )
110
134
def _wrapped (pathobj1 , pathobj2 , * args ):
135
+ should_use_original = False
136
+ if pathobj2 .filesystem .patcher :
137
+ skip_names = pathobj2 .filesystem .patcher ._skip_names
138
+ if is_called_from_skipped_module (skip_names = skip_names ):
139
+ should_use_original = True
140
+
141
+ if should_use_original :
142
+ return getattr (pathobj2 ._original_accessor , strfunc .__name__ )(
143
+ str (pathobj2 ),
144
+ str (pathobj1 ),
145
+ * args ,
146
+ )
111
147
return strfunc (pathobj2 .filesystem , str (pathobj2 ), str (pathobj1 ), * args )
112
148
113
149
return staticmethod (_wrapped )
@@ -573,6 +609,7 @@ def _from_parsed_parts(cls, drv, root, parts):
573
609
574
610
def _init (self , template = None ):
575
611
"""Initializer called from base class."""
612
+ self ._original_accessor = self ._accessor
576
613
# only needed until Python 3.10
577
614
self ._accessor = _fake_accessor
578
615
# only needed until Python 3.8
0 commit comments