Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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
edx
edx-platform
Commits
7c143803
Commit
7c143803
authored
Sep 26, 2014
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix BulkAssertionMixin so that it actually asserts the truth/falsity of the contained assertions
parent
c5ae921d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
1 deletions
+79
-1
common/lib/xmodule/xmodule/tests/__init__.py
+2
-1
common/lib/xmodule/xmodule/tests/test_bulk_assertions.py
+77
-0
No files found.
common/lib/xmodule/xmodule/tests/__init__.py
View file @
7c143803
...
...
@@ -193,7 +193,7 @@ class BulkAssertionManager(object):
self
.
_equal_actual
.
append
((
description
,
actual
))
def
run_assertions
(
self
):
s
elf
.
_test_case
.
assertEqual
(
self
.
_equal_expected
,
self
.
_equal_actual
)
s
uper
(
BulkAssertionTest
,
self
.
_test_case
)
.
assertEqual
(
self
.
_equal_expected
,
self
.
_equal_actual
)
class
BulkAssertionTest
(
unittest
.
TestCase
):
...
...
@@ -224,6 +224,7 @@ class BulkAssertionTest(unittest.TestCase):
self
.
_manager
.
assertEqual
(
expected
,
actual
,
message
)
else
:
super
(
BulkAssertionTest
,
self
)
.
assertEqual
(
expected
,
actual
,
message
)
assertEquals
=
assertEqual
class
CourseComparisonTest
(
BulkAssertionTest
):
...
...
common/lib/xmodule/xmodule/tests/test_bulk_assertions.py
0 → 100644
View file @
7c143803
import
ddt
from
xmodule.tests
import
BulkAssertionTest
@ddt.ddt
class
TestBulkAssertionTestCase
(
BulkAssertionTest
):
@ddt.data
(
(
'assertTrue'
,
True
),
(
'assertFalse'
,
False
),
(
'assertIs'
,
1
,
1
),
(
'assertIsNot'
,
1
,
2
),
(
'assertIsNone'
,
None
),
(
'assertIsNotNone'
,
1
),
(
'assertIn'
,
1
,
(
1
,
2
,
3
)),
(
'assertNotIn'
,
5
,
(
1
,
2
,
3
)),
(
'assertIsInstance'
,
1
,
int
),
(
'assertNotIsInstance'
,
'1'
,
int
),
(
'assertRaises'
,
KeyError
,
{}
.
__getitem__
,
'1'
),
)
@ddt.unpack
def
test_passing_asserts_passthrough
(
self
,
assertion
,
*
args
):
getattr
(
self
,
assertion
)(
*
args
)
@ddt.data
(
(
'assertTrue'
,
False
),
(
'assertFalse'
,
True
),
(
'assertIs'
,
1
,
2
),
(
'assertIsNot'
,
1
,
1
),
(
'assertIsNone'
,
1
),
(
'assertIsNotNone'
,
None
),
(
'assertIn'
,
5
,
(
1
,
2
,
3
)),
(
'assertNotIn'
,
1
,
(
1
,
2
,
3
)),
(
'assertIsInstance'
,
'1'
,
int
),
(
'assertNotIsInstance'
,
1
,
int
),
(
'assertRaises'
,
ValueError
,
lambda
:
None
),
)
@ddt.unpack
def
test_failing_asserts_passthrough
(
self
,
assertion
,
*
args
):
# Use super(BulkAssertionTest) to make sure we get un-adulturated assertions
with
super
(
BulkAssertionTest
,
self
)
.
assertRaises
(
AssertionError
):
getattr
(
self
,
assertion
)(
*
args
)
def
test_no_bulk_assert_equals
(
self
):
# Use super(BulkAssertionTest) to make sure we get un-adulturated assertions
with
super
(
BulkAssertionTest
,
self
)
.
assertRaises
(
AssertionError
):
self
.
assertEquals
(
1
,
2
)
@ddt.data
(
'assertEqual'
,
'assertEquals'
)
def
test_bulk_assert_equals
(
self
,
asserterFn
):
asserter
=
getattr
(
self
,
asserterFn
)
contextmanager
=
self
.
bulk_assertions
()
contextmanager
.
__enter__
()
super
(
BulkAssertionTest
,
self
)
.
assertIsNotNone
(
self
.
_manager
)
asserter
(
1
,
2
)
asserter
(
3
,
4
)
# Use super(BulkAssertionTest) to make sure we get un-adulturated assertions
with
super
(
BulkAssertionTest
,
self
)
.
assertRaises
(
AssertionError
):
contextmanager
.
__exit__
(
None
,
None
,
None
)
@ddt.data
(
'assertEqual'
,
'assertEquals'
)
def
test_bulk_assert_closed
(
self
,
asserterFn
):
asserter
=
getattr
(
self
,
asserterFn
)
with
self
.
bulk_assertions
():
asserter
(
1
,
1
)
asserter
(
2
,
2
)
# Use super(BulkAssertionTest) to make sure we get un-adulturated assertions
with
super
(
BulkAssertionTest
,
self
)
.
assertRaises
(
AssertionError
):
asserter
(
1
,
2
)
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