@@ -2263,59 +2263,6 @@ def wrapper(*args, **kwargs):
2263
2263
with_connectivity_check = network
2264
2264
2265
2265
2266
- class SimpleMock (object ):
2267
-
2268
- """
2269
- Poor man's mocking object
2270
-
2271
- Note: only works for new-style classes, assumes __getattribute__ exists.
2272
-
2273
- >>> a = type("Duck",(),{})
2274
- >>> a.attr1,a.attr2 ="fizz","buzz"
2275
- >>> b = SimpleMock(a,"attr1","bar")
2276
- >>> b.attr1 == "bar" and b.attr2 == "buzz"
2277
- True
2278
- >>> a.attr1 == "fizz" and a.attr2 == "buzz"
2279
- True
2280
- """
2281
-
2282
- def __init__ (self , obj , * args , ** kwds ):
2283
- assert (len (args ) % 2 == 0 )
2284
- attrs = kwds .get ("attrs" , {})
2285
- for k , v in zip (args [::2 ], args [1 ::2 ]):
2286
- # dict comprehensions break 2.6
2287
- attrs [k ] = v
2288
- self .attrs = attrs
2289
- self .obj = obj
2290
-
2291
- def __getattribute__ (self , name ):
2292
- attrs = object .__getattribute__ (self , "attrs" )
2293
- obj = object .__getattribute__ (self , "obj" )
2294
- return attrs .get (name , type (obj ).__getattribute__ (obj , name ))
2295
-
2296
-
2297
- @contextmanager
2298
- def stdin_encoding (encoding = None ):
2299
- """
2300
- Context manager for running bits of code while emulating an arbitrary
2301
- stdin encoding.
2302
-
2303
- >>> import sys
2304
- >>> _encoding = sys.stdin.encoding
2305
- >>> with stdin_encoding('AES'): sys.stdin.encoding
2306
- 'AES'
2307
- >>> sys.stdin.encoding==_encoding
2308
- True
2309
-
2310
- """
2311
- import sys
2312
-
2313
- _stdin = sys .stdin
2314
- sys .stdin = SimpleMock (sys .stdin , "encoding" , encoding )
2315
- yield
2316
- sys .stdin = _stdin
2317
-
2318
-
2319
2266
def assert_raises_regex (_exception , _regexp , _callable = None ,
2320
2267
* args , ** kwargs ):
2321
2268
r"""
0 commit comments