Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tic
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wenyuanbo
tic
Commits
9f0e8ffe
Commit
9f0e8ffe
authored
May 01, 2018
by
Tianqi Chen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PYTHON] Enable environment scoping (#33)
parent
7ab574b0
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
0 deletions
+18
-0
vta/python/vta/environment.py
+9
-0
vta/tests/python/unittest/test_environment.py
+9
-0
No files found.
vta/python/vta/environment.py
View file @
9f0e8ffe
...
@@ -143,6 +143,15 @@ class Environment(object):
...
@@ -143,6 +143,15 @@ class Environment(object):
self
.
mock_mode
=
False
self
.
mock_mode
=
False
self
.
_mock_env
=
None
self
.
_mock_env
=
None
self
.
_dev_ctx
=
None
self
.
_dev_ctx
=
None
self
.
_last_env
=
None
def
__enter__
(
self
):
self
.
_last_env
=
Environment
.
current
Environment
.
current
=
self
return
self
def
__exit__
(
self
,
ptype
,
value
,
trace
):
Environment
.
current
=
self
.
_last_env
def
pkg_config
(
self
):
def
pkg_config
(
self
):
"""PkgConfig instance"""
"""PkgConfig instance"""
...
...
vta/tests/python/unittest/test_environment.py
View file @
9f0e8ffe
...
@@ -6,6 +6,15 @@ def test_env():
...
@@ -6,6 +6,15 @@ def test_env():
mock
=
env
.
mock
mock
=
env
.
mock
assert
mock
.
alu
==
"skip_alu"
assert
mock
.
alu
==
"skip_alu"
def
test_env_scope
():
env
=
vta
.
get_env
()
cfg
=
env
.
pkg_config
()
.
cfg_dict
cfg
[
"TARGET"
]
=
"xyz"
with
vta
.
Environment
(
cfg
):
assert
vta
.
get_env
()
.
TARGET
==
"xyz"
assert
vta
.
get_env
()
.
TARGET
==
env
.
TARGET
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
test_env
()
test_env
()
test_env_scope
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment