summaryrefslogtreecommitdiff
path: root/.emacs.d.back/.python-environments/default/lib/python3.7/site-packages/epc/tests/test_dispatcher.py
diff options
context:
space:
mode:
authorRoger Gonzalez <rogergonzalez21@gmail.com>2020-04-08 10:38:14 -0300
committerRoger Gonzalez <rogergonzalez21@gmail.com>2020-04-08 10:38:14 -0300
commit5f0f2f90361a4c0a76478b288998595fc3ddebd2 (patch)
treefba8d30e376187e1b0b441314497bb1a70989f08 /.emacs.d.back/.python-environments/default/lib/python3.7/site-packages/epc/tests/test_dispatcher.py
parent47e1414d1be0069b158d0d0718988d72b0fb5d0d (diff)
Added my old emacs config
Diffstat (limited to '.emacs.d.back/.python-environments/default/lib/python3.7/site-packages/epc/tests/test_dispatcher.py')
-rw-r--r--.emacs.d.back/.python-environments/default/lib/python3.7/site-packages/epc/tests/test_dispatcher.py58
1 files changed, 58 insertions, 0 deletions
diff --git a/.emacs.d.back/.python-environments/default/lib/python3.7/site-packages/epc/tests/test_dispatcher.py b/.emacs.d.back/.python-environments/default/lib/python3.7/site-packages/epc/tests/test_dispatcher.py
new file mode 100644
index 00000000..cbce618b
--- /dev/null
+++ b/.emacs.d.back/.python-environments/default/lib/python3.7/site-packages/epc/tests/test_dispatcher.py
@@ -0,0 +1,58 @@
+# Copyright (C) 2012- Takafumi Arakaki
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+from ..core import EPCDispatcher
+from .utils import BaseTestCase
+
+
+class Dummy(object):
+ pass
+
+
+class TestEPCDispatcher(BaseTestCase):
+
+ def setUp(self):
+ self.dispatcher = EPCDispatcher()
+
+ def test_register_module(self):
+ import os
+ self.dispatcher.register_instance(os)
+ self.assertIs(self.dispatcher.get_method('chmod'), os.chmod)
+
+ def test_register_module_with_dotted_names(self):
+ import os
+ self.dispatcher.register_instance(os, allow_dotted_names=True)
+ self.assertIs(self.dispatcher.get_method('path.join'), os.path.join)
+
+ def test_error_on_private_method_access(self):
+ obj = Dummy()
+ obj._private_method = lambda: None
+ obj.sub = Dummy()
+ obj.sub._private_attribute = Dummy()
+ obj.sub._private_attribute.some_method = lambda: None
+ self.dispatcher.register_instance(obj, allow_dotted_names=True)
+ self.assertRaises(AttributeError, self.dispatcher.get_method,
+ '_private_method')
+ self.assertRaises(AttributeError, self.dispatcher.get_method,
+ 'obj.sub._private_attribute.some_method')
+
+ def test_instance_get_method(self):
+ always_me = lambda: None
+ obj = Dummy()
+ obj._get_method = lambda _: always_me
+ self.dispatcher.register_instance(obj)
+ self.assertIs(self.dispatcher.get_method('x'), always_me)
+ self.assertIs(self.dispatcher.get_method('y'), always_me)