From d66fab5388452a5c7a27ffaec8268d27ae44ad2d Mon Sep 17 00:00:00 2001 From: Uddeshya Singh Date: Thu, 14 Jun 2018 22:59:07 +0530 Subject: [PATCH 1/3] Update testing.py Removing SimpleMock test --- pandas/util/testing.py | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/pandas/util/testing.py b/pandas/util/testing.py index 233eba6490937..3fb29cb762520 100644 --- a/pandas/util/testing.py +++ b/pandas/util/testing.py @@ -2263,37 +2263,6 @@ def wrapper(*args, **kwargs): with_connectivity_check = network -class SimpleMock(object): - - """ - Poor man's mocking object - - Note: only works for new-style classes, assumes __getattribute__ exists. - - >>> a = type("Duck",(),{}) - >>> a.attr1,a.attr2 ="fizz","buzz" - >>> b = SimpleMock(a,"attr1","bar") - >>> b.attr1 == "bar" and b.attr2 == "buzz" - True - >>> a.attr1 == "fizz" and a.attr2 == "buzz" - True - """ - - def __init__(self, obj, *args, **kwds): - assert(len(args) % 2 == 0) - attrs = kwds.get("attrs", {}) - for k, v in zip(args[::2], args[1::2]): - # dict comprehensions break 2.6 - attrs[k] = v - self.attrs = attrs - self.obj = obj - - def __getattribute__(self, name): - attrs = object.__getattribute__(self, "attrs") - obj = object.__getattribute__(self, "obj") - return attrs.get(name, type(obj).__getattribute__(obj, name)) - - @contextmanager def stdin_encoding(encoding=None): """ From 64418b0029efed9cf04dc1232e42e4bb263e817d Mon Sep 17 00:00:00 2001 From: Uddeshya Singh Date: Fri, 15 Jun 2018 02:04:13 +0530 Subject: [PATCH 2/3] Update testing.py removed `stdin_encoding` --- pandas/util/testing.py | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/pandas/util/testing.py b/pandas/util/testing.py index 3fb29cb762520..aa2d21b23a72e 100644 --- a/pandas/util/testing.py +++ b/pandas/util/testing.py @@ -2262,29 +2262,6 @@ def wrapper(*args, **kwargs): with_connectivity_check = network - -@contextmanager -def stdin_encoding(encoding=None): - """ - Context manager for running bits of code while emulating an arbitrary - stdin encoding. - - >>> import sys - >>> _encoding = sys.stdin.encoding - >>> with stdin_encoding('AES'): sys.stdin.encoding - 'AES' - >>> sys.stdin.encoding==_encoding - True - - """ - import sys - - _stdin = sys.stdin - sys.stdin = SimpleMock(sys.stdin, "encoding", encoding) - yield - sys.stdin = _stdin - - def assert_raises_regex(_exception, _regexp, _callable=None, *args, **kwargs): r""" From edb4959c08b77af265fbf689e0bb8f5856bfc968 Mon Sep 17 00:00:00 2001 From: Uddeshya Singh Date: Fri, 15 Jun 2018 21:32:27 +0530 Subject: [PATCH 3/3] Update testing.py --- pandas/util/testing.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pandas/util/testing.py b/pandas/util/testing.py index aa2d21b23a72e..d26a2116fb3ce 100644 --- a/pandas/util/testing.py +++ b/pandas/util/testing.py @@ -2262,6 +2262,7 @@ def wrapper(*args, **kwargs): with_connectivity_check = network + def assert_raises_regex(_exception, _regexp, _callable=None, *args, **kwargs): r"""