Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
bbae00a4
Commit
bbae00a4
authored
7 years ago
by
John Eskew
Browse files
Options
Downloads
Patches
Plain Diff
Enable tox testing of system and commonlib via paver.
Add support for django_version option to support Django 1.8/1.11.
parent
dc7bd3db
Loading
Loading
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
pavelib/tests.py
+56
-10
56 additions, 10 deletions
pavelib/tests.py
pavelib/utils/test/suites/__init__.py
+1
-1
1 addition, 1 deletion
pavelib/utils/test/suites/__init__.py
pavelib/utils/test/suites/pytest_suite.py
+42
-6
42 additions, 6 deletions
pavelib/utils/test/suites/pytest_suite.py
with
99 additions
and
17 deletions
pavelib/tests.py
+
56
−
10
View file @
bbae00a4
...
...
@@ -30,6 +30,10 @@ __test__ = False # do not collect
(
"
test-id=
"
,
"
t
"
,
"
Test id
"
),
(
"
fail-fast
"
,
"
x
"
,
"
Fail suite on first failed test
"
),
(
"
fasttest
"
,
"
a
"
,
"
Run without collectstatic
"
),
make_option
(
"
--django_version
"
,
dest
=
"
django_version
"
,
help
=
"
Run against which Django version (1.8 -or- 1.11).
"
),
make_option
(
"
--eval-attr
"
,
dest
=
"
eval_attr
"
,
help
=
"
Only run tests matching given attribute expression.
"
...
...
@@ -66,28 +70,61 @@ def test_system(options, passthrough_options):
"""
system
=
getattr
(
options
,
'
system
'
,
None
)
test_id
=
getattr
(
options
,
'
test_id
'
,
None
)
django_version
=
getattr
(
options
,
'
django_version
'
,
None
)
assert
(
system
in
(
None
,
'
lms
'
,
'
cms
'
))
assert
(
django_version
in
(
None
,
'
1.8
'
,
'
1.11
'
))
def
_create_tox_system_test_suites
(
systems
):
system_tests
=
[]
test_paths
=
[]
# Add all test directories for the specified systems.
for
syst
in
systems
:
test_paths
.
extend
(
suites
.
default_system_test_dirs
(
syst
))
# Remove all duplicate paths.
test_paths
=
list
(
set
(
test_paths
))
for
test_id
in
test_paths
:
system
=
test_id
.
split
(
'
/
'
)[
0
]
syst
=
'
cms
'
if
system
in
[
'
common
'
,
'
openedx
'
,
'
lms
'
]:
syst
=
'
lms
'
system_tests
.
append
(
suites
.
SystemTestSuite
(
syst
,
passthrough_options
=
passthrough_options
,
test_id
=
test_id
,
**
options
.
test_system
))
return
system_tests
if
test_id
:
# Testing a single test ID.
# Ensure the proper system for the test id.
if
not
system
:
system
=
test_id
.
split
(
'
/
'
)[
0
]
if
system
in
[
'
common
'
,
'
openedx
'
]:
system
=
'
lms
'
options
.
test_system
[
'
test_id
'
]
=
test_id
if
test_id
or
system
:
system_tests
=
[
suites
.
SystemTestSuite
(
system
,
passthrough_options
=
passthrough_options
,
**
options
.
test_system
)]
else
:
system_tests
=
[]
for
syst
in
(
'
cms
'
,
'
lms
'
):
system_tests
.
append
(
suites
.
SystemTestSuite
(
syst
,
passthrough_options
=
passthrough_options
,
**
options
.
test_system
))
# Testing a single system -or- both systems.
if
system
:
systems
=
[
system
]
else
:
# No specified system or test_id, so run all tests of both systems.
systems
=
[
'
cms
'
,
'
lms
'
]
if
django_version
:
system_tests
=
_create_tox_system_test_suites
(
systems
)
else
:
system_tests
=
[]
for
syst
in
systems
:
system_tests
.
append
(
suites
.
SystemTestSuite
(
syst
,
passthrough_options
=
passthrough_options
,
**
options
.
test_system
))
test_suite
=
suites
.
PythonTestSuite
(
'
python tests
'
,
...
...
@@ -107,6 +144,10 @@ def test_system(options, passthrough_options):
(
"
test-id=
"
,
"
t
"
,
"
Test id
"
),
(
"
failed
"
,
"
f
"
,
"
Run only failed tests
"
),
(
"
fail-fast
"
,
"
x
"
,
"
Run only failed tests
"
),
make_option
(
"
--django_version
"
,
dest
=
"
django_version
"
,
help
=
"
Run against which Django version (1.8 -or- 1.11).
"
),
make_option
(
'
-c
'
,
'
--cov-args
'
,
default
=
''
,
help
=
'
adds as args to coverage for the test run
'
...
...
@@ -124,8 +165,12 @@ def test_lib(options, passthrough_options):
"""
lib
=
getattr
(
options
,
'
lib
'
,
None
)
test_id
=
getattr
(
options
,
'
test_id
'
,
lib
)
django_version
=
getattr
(
options
,
'
django_version
'
,
None
)
assert
(
django_version
in
(
None
,
'
1.8
'
,
'
1.11
'
))
if
test_id
:
# Testing a single test id.
if
'
/
'
in
test_id
:
lib
=
'
/
'
.
join
(
test_id
.
split
(
'
/
'
)[
0
:
3
])
else
:
...
...
@@ -137,6 +182,7 @@ def test_lib(options, passthrough_options):
**
options
.
test_lib
)]
else
:
# Testing all common/lib test dirs - plus pavelib.
lib_tests
=
[
suites
.
LibTestSuite
(
d
,
...
...
This diff is collapsed.
Click to expand it.
pavelib/utils/test/suites/__init__.py
+
1
−
1
View file @
bbae00a4
...
...
@@ -2,7 +2,7 @@
TestSuite class and subclasses
"""
from
.suite
import
TestSuite
from
.pytest_suite
import
PytestSuite
,
SystemTestSuite
,
LibTestSuite
from
.pytest_suite
import
PytestSuite
,
SystemTestSuite
,
LibTestSuite
,
default_system_test_dirs
from
.python_suite
import
PythonTestSuite
from
.js_suite
import
JsTestSuite
from
.acceptance_suite
import
AcceptanceTestSuite
...
...
This diff is collapsed.
Click to expand it.
pavelib/utils/test/suites/pytest_suite.py
+
42
−
6
View file @
bbae00a4
...
...
@@ -15,6 +15,27 @@ except ImportError:
__test__
=
False
# do not collect
def
default_system_test_dirs
(
system
):
"""
Return a list of all directories in which pytest should begin a search for tests.
"""
default_test_dirs
=
[
"
{system}/djangoapps
"
.
format
(
system
=
system
),
"
common/djangoapps
"
,
"
openedx/core/djangoapps
"
,
"
openedx/tests
"
,
"
openedx/core/lib
"
,
]
if
system
in
(
'
lms
'
,
'
cms
'
):
default_test_dirs
.
append
(
"
{system}/lib
"
.
format
(
system
=
system
))
if
system
==
'
lms
'
:
default_test_dirs
.
append
(
"
{system}/tests.py
"
.
format
(
system
=
system
))
default_test_dirs
.
append
(
"
openedx/core/djangolib
"
)
default_test_dirs
.
append
(
"
openedx/features
"
)
return
default_test_dirs
class
PytestSuite
(
TestSuite
):
"""
A subclass of TestSuite with extra methods that are specific
...
...
@@ -25,6 +46,13 @@ class PytestSuite(TestSuite):
self
.
failed_only
=
kwargs
.
get
(
'
failed_only
'
,
False
)
self
.
fail_fast
=
kwargs
.
get
(
'
fail_fast
'
,
False
)
self
.
run_under_coverage
=
kwargs
.
get
(
'
with_coverage
'
,
True
)
django_version
=
kwargs
.
get
(
'
django_version
'
,
None
)
if
django_version
is
None
:
self
.
django_toxenv
=
None
elif
django_version
==
'
1.11
'
:
self
.
django_toxenv
=
'
py27-django111
'
else
:
self
.
django_toxenv
=
'
py27-django18
'
self
.
report_dir
=
Env
.
REPORT_DIR
/
self
.
root
# If set, put reports for run in "unique" directories.
...
...
@@ -122,11 +150,15 @@ class SystemTestSuite(PytestSuite):
@property
def
cmd
(
self
):
cmd
=
[
'
pytest
'
,
if
self
.
django_toxenv
:
cmd
=
[
'
tox
'
,
'
-e
'
,
self
.
django_toxenv
,
'
--
'
]
else
:
cmd
=
[
'
pytest
'
]
cmd
.
extend
([
'
--ds={}
'
.
format
(
'
{}.envs.{}
'
.
format
(
self
.
root
,
self
.
settings
)),
'
--junitxml={}
'
.
format
(
self
.
report_dir
/
"
nosetests.xml
"
),
]
+
self
.
test_options_flags
])
cmd
.
extend
(
self
.
test_options_flags
)
if
self
.
verbosity
<
1
:
cmd
.
append
(
"
--quiet
"
)
elif
self
.
verbosity
>
1
:
...
...
@@ -205,12 +237,16 @@ class LibTestSuite(PytestSuite):
@property
def
cmd
(
self
):
cmd
=
[
"
pytest
"
,
if
self
.
django_toxenv
:
cmd
=
[
'
tox
'
,
'
-e
'
,
self
.
django_toxenv
,
'
--
'
]
else
:
cmd
=
[
'
pytest
'
]
cmd
.
extend
([
"
-p
"
,
"
no:randomly
"
,
"
--junitxml=
"
.
format
(
self
.
xunit_report
),
]
+
self
.
passthrough_options
+
self
.
test_options_flags
])
cmd
.
extend
(
self
.
passthrough_options
+
self
.
test_options_flags
)
if
self
.
verbosity
<
1
:
cmd
.
append
(
"
--quiet
"
)
elif
self
.
verbosity
>
1
:
...
...
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