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
ea27d19c
Commit
ea27d19c
authored
9 years ago
by
Piotr Mitros
Browse files
Options
Downloads
Patches
Plain Diff
Allow us to run tests from external XBlock repositories
parent
7a287dc6
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
openedx/tests/xblock_integration/test_external_xblocks.py
+53
-0
53 additions, 0 deletions
openedx/tests/xblock_integration/test_external_xblocks.py
with
53 additions
and
0 deletions
openedx/tests/xblock_integration/test_external_xblocks.py
0 → 100644
+
53
−
0
View file @
ea27d19c
"""
This will run tests on all XBlocks in the `xblock.test.v0`
entrypoint. Did you notice something about that entry point? It ends
with a v0. That means this is not finished. At some point, we might
stop running v0 tests, replacing them with test case failures, and
run v1 tests only.
That be the dragon here.
"""
import
pkg_resources
class
DuplicateXBlockTest
(
Exception
):
'''
This exception is shown if there are multiple entry points with the same
class name for a test. In most cases, this means you have two versions
of the same XBlock installed, or two XBlocks with namespace collisions. In
either case, it
'
d be nice to resolve (likely by renaming tests as they
come in, hopefully still being careful to catch collisions which might
effect deployed XBlocks. See discussion at:
https://github.com/edx/edx-platform/pull/11032#discussion_r48097392).
'''
pass
class
InvalidTestName
(
Exception
):
'''
This means you have an entry point for a test that does not correspond
to a properly named test class. For example, if you cut-and-paste entry
points in `setup.py`, and forgot to repoint the class (so it points to
`DoneXBlock` instead of `TestDone`), or otherwise made an error, you
will see this exception.
'''
pass
xblock_loaded
=
False
# pylint: disable=invalid-name
for
entrypoint
in
pkg_resources
.
iter_entry_points
(
group
=
"
xblock.test.v0
"
):
# pylint: disable=no-member
plugin
=
entrypoint
.
load
()
classname
=
plugin
.
__name__
if
classname
in
globals
():
raise
DuplicateXBlockTest
(
classname
)
if
not
classname
.
startswith
(
"
Test
"
):
raise
InvalidTestName
(
"
Test class should start with
'
Test
'
:
"
+
classname
)
# This should never happen, but while we're testing for class name
# validity, we figured it was okay to be a little overly defensive.
# See discussion at:
# https://github.com/edx/edx-platform/pull/11032#discussion_r48097392
if
not
classname
.
replace
(
"
_
"
,
""
).
isalnum
():
raise
InvalidTestName
(
"
Python variables should be letters, numbers, and underscores:
"
+
classname
)
globals
()[
classname
]
=
plugin
print
"
Loading XBlock test:
"
+
classname
xblock_loaded
=
True
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