Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
satella
Manage
Activity
Members
Labels
Plan
Issues
1
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
public
satella
Commits
777eed4f
Commit
777eed4f
authored
5 years ago
by
Piotr Maślanka
Browse files
Options
Downloads
Patches
Plain Diff
tests for Proxy
parent
1b0cd9d0
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
satella/coding/structures/proxy.py
+39
-0
39 additions, 0 deletions
satella/coding/structures/proxy.py
tests/test_coding/test_proxy.py
+11
-0
11 additions, 0 deletions
tests/test_coding/test_proxy.py
with
50 additions
and
0 deletions
satella/coding/structures/proxy.py
+
39
−
0
View file @
777eed4f
...
...
@@ -199,6 +199,12 @@ class Proxy(tp.Generic[T]):
def
__repr__
(
self
)
->
str
:
return
repr
(
self
.
__obj
)
def
__oct__
(
self
)
->
str
:
return
oct
(
self
.
__obj
)
def
__hex__
(
self
)
->
str
:
return
hex
(
self
.
__obj
)
def
__abs__
(
self
):
return
abs
(
self
.
__obj
)
...
...
@@ -214,6 +220,39 @@ class Proxy(tp.Generic[T]):
def
__xor__
(
self
,
other
):
return
self
.
__obj
^
other
def
__radd__
(
self
,
other
):
return
other
+
self
.
__obj
def
__rsub__
(
self
,
other
):
return
other
-
self
.
__obj
def
__rmul__
(
self
,
other
):
return
other
*
self
.
__obj
def
__rtruediv__
(
self
,
other
):
return
other
/
self
.
__obj
def
__rfloordiv__
(
self
,
other
):
return
other
//
self
.
__obj
def
__rlshift__
(
self
,
other
):
return
other
<<
self
.
__obj
def
__rrshift__
(
self
,
other
):
return
other
>>
self
.
__obj
def
__rpow__
(
self
,
other
):
return
other
**
self
.
__obj
def
__ror__
(
self
,
other
):
return
other
|
self
.
__obj
def
__rand__
(
self
,
other
):
return
other
&
self
.
__obj
def
__rxor__
(
self
,
other
):
return
other
^
self
.
__obj
def
__ior__
(
self
,
other
)
->
'
Proxy
'
:
self
.
__obj
|=
other
return
self
...
...
This diff is collapsed.
Click to expand it.
tests/test_coding/test_proxy.py
+
11
−
0
View file @
777eed4f
...
...
@@ -18,9 +18,20 @@ class TestProxy(unittest.TestCase):
self
.
assertEqual
(
math
.
floor
(
a
),
5
)
self
.
assertEqual
(
round
(
a
),
5
)
self
.
assertEqual
(
math
.
trunc
(
a
),
5
)
self
.
assertEqual
(
-
0.25
+
a
,
5.0
)
self
.
assertEqual
(
2
*
a
,
10.5
)
self
.
assertEqual
(
2
/
a
,
2
/
5.25
)
self
.
assertEqual
(
2
//
a
,
0
)
self
.
assertEqual
(
2
**
a
,
2
**
5.25
)
a
=
Proxy
(
2
)
self
.
assertEqual
(
a
&
2
,
2
)
self
.
assertEqual
(
a
|
1
,
3
)
self
.
assertEqual
(
a
<<
1
,
4
)
self
.
assertEqual
(
a
>>
1
,
1
)
self
.
assertNotEqual
(
a
,
6
)
self
.
assertEqual
(
2
&
a
,
2
)
self
.
assertEqual
(
1
|
a
,
3
)
self
.
assertEqual
(
1
<<
a
,
4
)
self
.
assertEqual
(
1
>>
a
,
0
)
self
.
assertEqual
(
hex
(
a
),
'
0x2
'
)
self
.
assertEqual
(
oct
(
a
),
'
0o2
'
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment