Skip to content
Snippets Groups Projects
Commit be13b8d9 authored by Piotr Maślanka's avatar Piotr Maślanka
Browse files

tests for Proxy

parent e56ef28f
No related branches found
Tags v2.1.10
No related merge requests found
......@@ -31,8 +31,7 @@ class Proxy(tp.Generic[T]):
Note that in-place operations will return the Proxy itself, whereas simple addition will shed
this proxy, returning object wrapped plus something.
Note that proxies are considered to be the type of the object that they wrap,
as well as considered to be of type Proxy.
Only __isinstance__ check is not overridden, due to Python limitations.
Please access this object in your descendant classes via
......@@ -41,7 +40,7 @@ class Proxy(tp.Generic[T]):
Please note that this class does not overload the descriptor protocol,
not the pickle interface!
Note that this overloads both __repr__ and __str__, which may prove confusing.
Note that this overloads __repr__, __str__ and __dir__, which may prove confusing.
Handle this in your descendant classes.
:param object_to_wrap: object to wrap
......
......@@ -6,7 +6,10 @@ from satella.coding.structures import Proxy
class TestProxy(unittest.TestCase):
def test_proxy(self):
a = Proxy(5.25, True)
self.assertIsInstance(a+2, Proxy)
a = Proxy(5.25)
self.assertNotIsInstance(a+2, Proxy)
self.assertEqual(int(a), 5)
self.assertEqual(float(a), 5.25)
self.assertEqual(a - 0.25, 5.0)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment