Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ColossalAI
Commits
91cd34e6
"...Chat/git@developer.sourcefind.cn:OpenDAS/colossalai.git" did not exist on "493a5efeab03ec0b9bf23dbf6e653fe2eb9c18ce"
Unverified
Commit
91cd34e6
authored
Oct 14, 2022
by
Frank Lee
Committed by
GitHub
Oct 14, 2022
Browse files
[unittest] added doc for the pytest wrapper (#1704)
parent
451cd72d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
1 deletion
+25
-1
colossalai/testing/pytest_wrapper.py
colossalai/testing/pytest_wrapper.py
+23
-0
tests/test_auto_parallel/test_shape_consistency_pass.py
tests/test_auto_parallel/test_shape_consistency_pass.py
+2
-1
No files found.
colossalai/testing/pytest_wrapper.py
View file @
91cd34e6
"""
This file will not be automatically imported by `colossalai.testing`
as this file has a dependency on `pytest`. Therefore, you need to
explicitly import this file `from colossalai.testing.pytest_wrapper import <func>`.from
"""
import
pytest
import
os
...
...
@@ -6,6 +12,23 @@ def run_on_environment_flag(name: str):
"""
Conditionally run a test based on the environment variable. If this environment variable is set
to 1, this test will be executed. Otherwise, this test is skipped. The environment variable is default to 0.
Args:
name (str): the name of the environment variable flag.
Usage:
# in your pytest file
@run_on_environment_flag(name='SOME_FLAG')
def test_for_something():
do_something()
# in your terminal
# this will execute your test
SOME_FLAG=1 pytest test_for_something.py
# this will skip your test
pytest test_for_something.py
"""
assert
isinstance
(
name
,
str
)
flag
=
os
.
environ
.
get
(
name
.
upper
(),
'0'
)
...
...
tests/test_auto_parallel/test_shape_consistency_pass.py
View file @
91cd34e6
...
...
@@ -18,6 +18,7 @@ from colossalai.device.device_mesh import DeviceMesh
from
colossalai.fx.passes.experimental.adding_shape_consistency_pass_v2
import
shape_consistency_pass
,
solution_annotatation_pass
from
colossalai.auto_parallel.solver.solver
import
Solver_V2
from
colossalai.auto_parallel.solver.options
import
SolverOptions
from
colossalai.testing.pytest_wrapper
import
run_on_environment_flag
class
ConvModel
(
nn
.
Module
):
...
...
@@ -73,7 +74,7 @@ def check_apply(rank, world_size, port):
assert
output
.
equal
(
origin_output
)
@
pytest
.
mark
.
skip
(
"for higher testing speed"
)
@
run_on_environment_flag
(
name
=
'AUTO_PARALLEL'
)
@
pytest
.
mark
.
dist
@
rerun_if_address_is_in_use
()
def
test_apply
():
...
...
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