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
d8af4afe
Commit
d8af4afe
authored
1 year ago
by
Piotr Maślanka
Browse files
Options
Downloads
Patches
Plain Diff
Contexts are experimental
Change-Id: I450ace29716a81eacb1b1c5b9326cada9ff516c4
parent
c58184c0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
CHANGELOG.md
+1
-0
1 addition, 0 deletions
CHANGELOG.md
satella/__init__.py
+1
-1
1 addition, 1 deletion
satella/__init__.py
satella/coding/environment.py
+4
-0
4 additions, 0 deletions
satella/coding/environment.py
tests/test_coding/test_environment.py
+14
-0
14 additions, 0 deletions
tests/test_coding/test_environment.py
with
20 additions
and
1 deletion
CHANGELOG.md
+
1
−
0
View file @
d8af4afe
# v2.24.2
# v2.24.2
*
added DeferredValue
*
added DeferredValue
*
satella.coding.Context are considered experimental
This diff is collapsed.
Click to expand it.
satella/__init__.py
+
1
−
1
View file @
d8af4afe
__version__
=
'
2.24.2a
2
'
__version__
=
'
2.24.2a
3
'
This diff is collapsed.
Click to expand it.
satella/coding/environment.py
+
4
−
0
View file @
d8af4afe
...
@@ -2,6 +2,7 @@ from __future__ import annotations
...
@@ -2,6 +2,7 @@ from __future__ import annotations
import
threading
import
threading
import
typing
as
tp
import
typing
as
tp
import
warnings
from
satella.coding.typing
import
V
from
satella.coding.typing
import
V
...
@@ -13,9 +14,12 @@ THEY_HATIN = object()
...
@@ -13,9 +14,12 @@ THEY_HATIN = object()
class
Context
:
class
Context
:
"""
"""
New layer of environment. Can have it
'
s own variables, or can hoist them onto the parent.
New layer of environment. Can have it
'
s own variables, or can hoist them onto the parent.
.. warning:: This is considered experimental. I just haven
'
t found out a good use case for it yet.
"""
"""
def
__init__
(
self
,
parent
:
tp
.
Optional
[
Context
]
=
None
,
**
variables
):
def
__init__
(
self
,
parent
:
tp
.
Optional
[
Context
]
=
None
,
**
variables
):
warnings
.
warn
(
'
This is experimental
'
,
RuntimeWarning
)
self
.
parent
=
parent
self
.
parent
=
parent
self
.
variables
=
variables
self
.
variables
=
variables
self
.
bool
=
None
self
.
bool
=
None
...
...
This diff is collapsed.
Click to expand it.
satella/debu
g/test_environment.py
→
tests/test_codin
g/test_environment.py
+
14
−
0
View file @
d8af4afe
import
threading
import
unittest
import
unittest
from
satella.coding.environment
import
Context
from
satella.coding.environment
import
Context
...
@@ -12,6 +13,19 @@ class TestEnvs(unittest.TestCase):
...
@@ -12,6 +13,19 @@ class TestEnvs(unittest.TestCase):
with
Context
()
as
new_ctxt
:
with
Context
()
as
new_ctxt
:
self
.
assertEqual
(
new_ctxt
.
value
,
5
)
self
.
assertEqual
(
new_ctxt
.
value
,
5
)
def
test_threads
(
self
):
ctxt
=
Context
.
get
()
ctxt
.
value
=
2
with
ctxt
:
def
thread
():
with
Context
()
as
new_ctxt
:
self
.
assertEqual
(
new_ctxt
.
value
,
2
)
new_ctxt
.
value2
=
2
thr
=
threading
.
Thread
(
target
=
thread
)
thr
.
start
()
thr
.
join
()
self
.
assertRaises
(
AttributeError
,
lambda
:
ctxt
.
value2
)
def
test_push
(
self
):
def
test_push
(
self
):
ctxt
=
Context
.
get
()
ctxt
=
Context
.
get
()
ctxt
.
value
=
5
ctxt
.
value
=
5
...
...
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