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
9f89112e
Commit
9f89112e
authored
Oct 29, 2015
by
Muzaffar yousaf
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #10419 from edx/muzaffar/pep8-fixes
Fix pep8 & pylint warnings.
parents
d9751a85
35884195
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
33 additions
and
32 deletions
+33
-32
common/lib/capa/capa/tests/test_html_render.py
+4
-1
common/lib/capa/capa/tests/test_input_templates.py
+1
-2
common/lib/capa/capa/tests/test_inputtypes.py
+4
-4
common/lib/xmodule/xmodule/tests/test_capa_module.py
+10
-11
common/lib/xmodule/xmodule/tests/test_combined_open_ended.py
+0
-0
common/lib/xmodule/xmodule/tests/test_crowdsource_hinter.py
+3
-3
common/lib/xmodule/xmodule/tests/test_import.py
+4
-4
common/lib/xmodule/xmodule/tests/test_progress.py
+4
-4
common/lib/xmodule/xmodule/tests/test_self_assessment.py
+1
-1
openedx/core/djangoapps/credit/tests/test_api.py
+1
-1
openedx/core/djangoapps/user_api/accounts/tests/test_api.py
+1
-1
No files found.
common/lib/capa/capa/tests/test_html_render.py
View file @
9f89112e
...
@@ -124,7 +124,10 @@ class CapaHtmlRenderTest(unittest.TestCase):
...
@@ -124,7 +124,10 @@ class CapaHtmlRenderTest(unittest.TestCase):
rendered_html
=
etree
.
XML
(
problem
.
get_html
())
rendered_html
=
etree
.
XML
(
problem
.
get_html
())
# expect the javascript is still present in the rendered html
# expect the javascript is still present in the rendered html
self
.
assertTrue
(
"<script type=
\"
text/javascript
\"
>function(){}</script>"
in
etree
.
tostring
(
rendered_html
))
self
.
assertIn
(
"<script type=
\"
text/javascript
\"
>function(){}</script>"
,
etree
.
tostring
(
rendered_html
)
# pylint: disable=no-member
)
def
test_render_response_xml
(
self
):
def
test_render_response_xml
(
self
):
# Generate some XML for a string response
# Generate some XML for a string response
...
...
common/lib/capa/capa/tests/test_input_templates.py
View file @
9f89112e
...
@@ -105,8 +105,7 @@ class TemplateTestCase(unittest.TestCase):
...
@@ -105,8 +105,7 @@ class TemplateTestCase(unittest.TestCase):
If no elements are found, the assertion fails.
If no elements are found, the assertion fails.
"""
"""
element_list
=
xml_root
.
xpath
(
xpath
)
element_list
=
xml_root
.
xpath
(
xpath
)
self
.
assertTrue
(
len
(
element_list
)
>
0
,
self
.
assertGreater
(
len
(
element_list
),
0
,
"Could not find element at '
%
s'"
%
str
(
xpath
))
"Could not find element at '
%
s'"
%
str
(
xpath
))
if
exact
:
if
exact
:
self
.
assertEqual
(
text
,
element_list
[
0
]
.
text
)
self
.
assertEqual
(
text
,
element_list
[
0
]
.
text
)
...
...
common/lib/capa/capa/tests/test_inputtypes.py
View file @
9f89112e
...
@@ -555,8 +555,8 @@ class MatlabTest(unittest.TestCase):
...
@@ -555,8 +555,8 @@ class MatlabTest(unittest.TestCase):
response
=
self
.
the_input
.
handle_ajax
(
"plot"
,
data
)
response
=
self
.
the_input
.
handle_ajax
(
"plot"
,
data
)
self
.
assertFalse
(
response
[
'success'
])
self
.
assertFalse
(
response
[
'success'
])
self
.
assertEqual
(
response
[
'message'
],
error_message
)
self
.
assertEqual
(
response
[
'message'
],
error_message
)
self
.
assert
True
(
'queuekey'
not
in
self
.
the_input
.
input_state
)
self
.
assert
NotIn
(
'queuekey'
,
self
.
the_input
.
input_state
)
self
.
assert
True
(
'queuestate'
not
in
self
.
the_input
.
input_state
)
self
.
assert
NotIn
(
'queuestate'
,
self
.
the_input
.
input_state
)
@patch
(
'capa.inputtypes.time.time'
,
return_value
=
10
)
@patch
(
'capa.inputtypes.time.time'
,
return_value
=
10
)
def
test_ungraded_response_success
(
self
,
time
):
def
test_ungraded_response_success
(
self
,
time
):
...
@@ -594,7 +594,7 @@ class MatlabTest(unittest.TestCase):
...
@@ -594,7 +594,7 @@ class MatlabTest(unittest.TestCase):
the_input
.
ungraded_response
(
queue_msg
,
'abc'
)
the_input
.
ungraded_response
(
queue_msg
,
'abc'
)
self
.
assertEqual
(
input_state
[
'queuekey'
],
queuekey
)
self
.
assertEqual
(
input_state
[
'queuekey'
],
queuekey
)
self
.
assertEqual
(
input_state
[
'queuestate'
],
'queued'
)
self
.
assertEqual
(
input_state
[
'queuestate'
],
'queued'
)
self
.
assert
False
(
'queue_msg'
in
input_state
)
self
.
assert
NotIn
(
'queue_msg'
,
input_state
)
@patch
(
'capa.inputtypes.time.time'
,
return_value
=
20
)
@patch
(
'capa.inputtypes.time.time'
,
return_value
=
20
)
def
test_matlab_response_timeout_not_exceeded
(
self
,
time
):
def
test_matlab_response_timeout_not_exceeded
(
self
,
time
):
...
@@ -1076,7 +1076,7 @@ class ChemicalEquationTest(unittest.TestCase):
...
@@ -1076,7 +1076,7 @@ class ChemicalEquationTest(unittest.TestCase):
)
)
self
.
assertIn
(
'error'
,
response
)
self
.
assertIn
(
'error'
,
response
)
self
.
assert
True
(
"Couldn't parse formula"
in
response
[
'error'
])
self
.
assert
In
(
"Couldn't parse formula"
,
response
[
'error'
])
@patch
(
'capa.inputtypes.log'
)
@patch
(
'capa.inputtypes.log'
)
def
test_ajax_other_err
(
self
,
mock_log
):
def
test_ajax_other_err
(
self
,
mock_log
):
...
...
common/lib/xmodule/xmodule/tests/test_capa_module.py
View file @
9f89112e
...
@@ -449,15 +449,14 @@ class CapaModuleTest(unittest.TestCase):
...
@@ -449,15 +449,14 @@ class CapaModuleTest(unittest.TestCase):
# and that we get the same values back
# and that we get the same values back
for
key
in
result
.
keys
():
for
key
in
result
.
keys
():
original_key
=
"input_"
+
key
original_key
=
"input_"
+
key
self
.
assertTrue
(
original_key
in
valid_get_dict
,
self
.
assertIn
(
original_key
,
valid_get_dict
,
"Output dict should have key
%
s"
%
original_key
)
"Output dict should have key
%
s"
%
original_key
)
self
.
assertEqual
(
valid_get_dict
[
original_key
],
result
[
key
])
self
.
assertEqual
(
valid_get_dict
[
original_key
],
result
[
key
])
# Valid GET param dict with list keys
# Valid GET param dict with list keys
# Each tuple represents a single parameter in the query string
# Each tuple represents a single parameter in the query string
valid_get_dict
=
MultiDict
(((
'input_2[]'
,
'test1'
),
(
'input_2[]'
,
'test2'
)))
valid_get_dict
=
MultiDict
(((
'input_2[]'
,
'test1'
),
(
'input_2[]'
,
'test2'
)))
result
=
CapaModule
.
make_dict_of_responses
(
valid_get_dict
)
result
=
CapaModule
.
make_dict_of_responses
(
valid_get_dict
)
self
.
assert
True
(
'2'
in
result
)
self
.
assert
In
(
'2'
,
result
)
self
.
assertEqual
([
'test1'
,
'test2'
],
result
[
'2'
])
self
.
assertEqual
([
'test1'
,
'test2'
],
result
[
'2'
])
# If we use [] at the end of a key name, we should always
# If we use [] at the end of a key name, we should always
...
@@ -730,7 +729,7 @@ class CapaModuleTest(unittest.TestCase):
...
@@ -730,7 +729,7 @@ class CapaModuleTest(unittest.TestCase):
result
=
module
.
check_problem
(
get_request_dict
)
result
=
module
.
check_problem
(
get_request_dict
)
# Expect an AJAX alert message in 'success'
# Expect an AJAX alert message in 'success'
self
.
assert
True
(
error_msg
in
result
[
'success'
])
self
.
assert
In
(
error_msg
,
result
[
'success'
])
def
test_check_problem_error_nonascii
(
self
):
def
test_check_problem_error_nonascii
(
self
):
...
@@ -781,10 +780,10 @@ class CapaModuleTest(unittest.TestCase):
...
@@ -781,10 +780,10 @@ class CapaModuleTest(unittest.TestCase):
result
=
module
.
check_problem
(
get_request_dict
)
result
=
module
.
check_problem
(
get_request_dict
)
# Expect an AJAX alert message in 'success'
# Expect an AJAX alert message in 'success'
self
.
assert
True
(
'test error'
in
result
[
'success'
])
self
.
assert
In
(
'test error'
,
result
[
'success'
])
# We DO include traceback information for staff users
# We DO include traceback information for staff users
self
.
assert
True
(
'Traceback'
in
result
[
'success'
])
self
.
assert
In
(
'Traceback'
,
result
[
'success'
])
# Expect that the number of attempts is NOT incremented
# Expect that the number of attempts is NOT incremented
self
.
assertEqual
(
module
.
attempts
,
1
)
self
.
assertEqual
(
module
.
attempts
,
1
)
...
@@ -806,7 +805,7 @@ class CapaModuleTest(unittest.TestCase):
...
@@ -806,7 +805,7 @@ class CapaModuleTest(unittest.TestCase):
self
.
assertTrue
(
'success'
in
result
and
result
[
'success'
])
self
.
assertTrue
(
'success'
in
result
and
result
[
'success'
])
# Expect that the problem HTML is retrieved
# Expect that the problem HTML is retrieved
self
.
assert
True
(
'html'
in
result
)
self
.
assert
In
(
'html'
,
result
)
self
.
assertEqual
(
result
[
'html'
],
"<div>Test HTML</div>"
)
self
.
assertEqual
(
result
[
'html'
],
"<div>Test HTML</div>"
)
# Expect that the problem was reset
# Expect that the problem was reset
...
@@ -852,7 +851,7 @@ class CapaModuleTest(unittest.TestCase):
...
@@ -852,7 +851,7 @@ class CapaModuleTest(unittest.TestCase):
self
.
assertEqual
(
result
[
'success'
],
'correct'
)
self
.
assertEqual
(
result
[
'success'
],
'correct'
)
# Expect that we get no HTML
# Expect that we get no HTML
self
.
assert
False
(
'contents'
in
result
)
self
.
assert
NotIn
(
'contents'
,
result
)
# Expect that the number of attempts is not incremented
# Expect that the number of attempts is not incremented
self
.
assertEqual
(
module
.
attempts
,
1
)
self
.
assertEqual
(
module
.
attempts
,
1
)
...
@@ -1263,7 +1262,7 @@ class CapaModuleTest(unittest.TestCase):
...
@@ -1263,7 +1262,7 @@ class CapaModuleTest(unittest.TestCase):
self
.
assertEqual
(
bool
(
context
[
'save_button'
]),
show_save_button
)
self
.
assertEqual
(
bool
(
context
[
'save_button'
]),
show_save_button
)
# Assert that the encapsulated html contains the original html
# Assert that the encapsulated html contains the original html
self
.
assert
True
(
html
in
html_encapsulated
)
self
.
assert
In
(
html
,
html_encapsulated
)
demand_xml
=
"""
demand_xml
=
"""
<problem>
<problem>
...
@@ -1355,7 +1354,7 @@ class CapaModuleTest(unittest.TestCase):
...
@@ -1355,7 +1354,7 @@ class CapaModuleTest(unittest.TestCase):
# Check the rendering context
# Check the rendering context
render_args
,
_
=
module
.
system
.
render_template
.
call_args
render_args
,
_
=
module
.
system
.
render_template
.
call_args
context
=
render_args
[
1
]
context
=
render_args
[
1
]
self
.
assert
True
(
"error"
in
context
[
'problem'
][
'html'
])
self
.
assert
In
(
"error"
,
context
[
'problem'
][
'html'
])
# Expect that the module has created a new dummy problem with the error
# Expect that the module has created a new dummy problem with the error
self
.
assertNotEqual
(
original_problem
,
module
.
lcp
)
self
.
assertNotEqual
(
original_problem
,
module
.
lcp
)
...
@@ -1385,7 +1384,7 @@ class CapaModuleTest(unittest.TestCase):
...
@@ -1385,7 +1384,7 @@ class CapaModuleTest(unittest.TestCase):
# Check the rendering context
# Check the rendering context
render_args
,
_
=
module
.
system
.
render_template
.
call_args
render_args
,
_
=
module
.
system
.
render_template
.
call_args
context
=
render_args
[
1
]
context
=
render_args
[
1
]
self
.
assert
True
(
error_msg
in
context
[
'problem'
][
'html'
])
self
.
assert
In
(
error_msg
,
context
[
'problem'
][
'html'
])
@ddt.data
(
@ddt.data
(
'false'
,
'false'
,
...
...
common/lib/xmodule/xmodule/tests/test_combined_open_ended.py
View file @
9f89112e
This diff is collapsed.
Click to expand it.
common/lib/xmodule/xmodule/tests/test_crowdsource_hinter.py
View file @
9f89112e
...
@@ -554,9 +554,9 @@ class CrowdsourceHinterTest(unittest.TestCase):
...
@@ -554,9 +554,9 @@ class CrowdsourceHinterTest(unittest.TestCase):
mock_module
.
get_hint
=
fake_get_hint
mock_module
.
get_hint
=
fake_get_hint
json_in
=
{
'problem_name'
:
'42.5'
}
json_in
=
{
'problem_name'
:
'42.5'
}
out
=
json
.
loads
(
mock_module
.
handle_ajax
(
'get_hint'
,
json_in
))[
'contents'
]
out
=
json
.
loads
(
mock_module
.
handle_ajax
(
'get_hint'
,
json_in
))[
'contents'
]
self
.
assert
True
(
'This is the best hint.'
in
out
)
self
.
assert
In
(
'This is the best hint.'
,
out
)
self
.
assert
True
(
'A random hint'
in
out
)
self
.
assert
In
(
'A random hint'
,
out
)
self
.
assert
True
(
'Another random hint'
in
out
)
self
.
assert
In
(
'Another random hint'
,
out
)
def
test_template_feedback
(
self
):
def
test_template_feedback
(
self
):
"""
"""
...
...
common/lib/xmodule/xmodule/tests/test_import.py
View file @
9f89112e
...
@@ -225,18 +225,18 @@ class ImportTestCase(BaseCourseTestCase):
...
@@ -225,18 +225,18 @@ class ImportTestCase(BaseCourseTestCase):
self
.
assertEqual
(
course_xml
.
attrib
[
'unicorn'
],
unicorn_color
)
self
.
assertEqual
(
course_xml
.
attrib
[
'unicorn'
],
unicorn_color
)
# the course and org tags should be _only_ in the pointer
# the course and org tags should be _only_ in the pointer
self
.
assert
True
(
'course'
not
in
course_xml
.
attrib
)
self
.
assert
NotIn
(
'course'
,
course_xml
.
attrib
)
self
.
assert
True
(
'org'
not
in
course_xml
.
attrib
)
self
.
assert
NotIn
(
'org'
,
course_xml
.
attrib
)
# did we successfully strip the url_name from the definition contents?
# did we successfully strip the url_name from the definition contents?
self
.
assert
True
(
'url_name'
not
in
course_xml
.
attrib
)
self
.
assert
NotIn
(
'url_name'
,
course_xml
.
attrib
)
# Does the chapter tag now have a due attribute?
# Does the chapter tag now have a due attribute?
# hardcoded path to child
# hardcoded path to child
with
descriptor
.
runtime
.
export_fs
.
open
(
'chapter/ch.xml'
)
as
f
:
with
descriptor
.
runtime
.
export_fs
.
open
(
'chapter/ch.xml'
)
as
f
:
chapter_xml
=
etree
.
fromstring
(
f
.
read
())
chapter_xml
=
etree
.
fromstring
(
f
.
read
())
self
.
assertEqual
(
chapter_xml
.
tag
,
'chapter'
)
self
.
assertEqual
(
chapter_xml
.
tag
,
'chapter'
)
self
.
assert
False
(
'due'
in
chapter_xml
.
attrib
)
self
.
assert
NotIn
(
'due'
,
chapter_xml
.
attrib
)
def
test_metadata_import_export
(
self
):
def
test_metadata_import_export
(
self
):
"""Two checks:
"""Two checks:
...
...
common/lib/xmodule/xmodule/tests/test_progress.py
View file @
9f89112e
...
@@ -127,12 +127,12 @@ class ProgressTest(unittest.TestCase):
...
@@ -127,12 +127,12 @@ class ProgressTest(unittest.TestCase):
prg1
=
Progress
(
1
,
2
)
prg1
=
Progress
(
1
,
2
)
prg2
=
Progress
(
2
,
4
)
prg2
=
Progress
(
2
,
4
)
prg3
=
Progress
(
1
,
2
)
prg3
=
Progress
(
1
,
2
)
self
.
assert
True
(
prg1
==
prg3
)
self
.
assert
Equal
(
prg1
,
prg3
)
self
.
assert
False
(
prg1
==
prg2
)
self
.
assert
NotEqual
(
prg1
,
prg2
)
# Check != while we're at it
# Check != while we're at it
self
.
assert
True
(
prg1
!=
prg2
)
self
.
assert
NotEqual
(
prg1
,
prg2
)
self
.
assert
False
(
prg1
!=
prg3
)
self
.
assert
Equal
(
prg1
,
prg3
)
class
ModuleProgressTest
(
unittest
.
TestCase
):
class
ModuleProgressTest
(
unittest
.
TestCase
):
...
...
common/lib/xmodule/xmodule/tests/test_self_assessment.py
View file @
9f89112e
...
@@ -78,7 +78,7 @@ class SelfAssessmentTest(unittest.TestCase):
...
@@ -78,7 +78,7 @@ class SelfAssessmentTest(unittest.TestCase):
def
test_get_html
(
self
):
def
test_get_html
(
self
):
html
=
self
.
module
.
get_html
(
self
.
module
.
system
)
html
=
self
.
module
.
get_html
(
self
.
module
.
system
)
self
.
assert
True
(
"This is sample prompt text"
in
html
)
self
.
assert
In
(
"This is sample prompt text"
,
html
)
def
test_self_assessment_flow
(
self
):
def
test_self_assessment_flow
(
self
):
responses
=
{
'assessment'
:
'0'
,
'score_list[]'
:
[
'0'
,
'0'
]}
responses
=
{
'assessment'
:
'0'
,
'score_list[]'
:
[
'0'
,
'0'
]}
...
...
openedx/core/djangoapps/credit/tests/test_api.py
View file @
9f89112e
...
@@ -642,7 +642,7 @@ class CreditProviderIntegrationApiTests(CreditApiTestBase):
...
@@ -642,7 +642,7 @@ class CreditProviderIntegrationApiTests(CreditApiTestBase):
# Validate the timestamp
# Validate the timestamp
self
.
assertIn
(
'timestamp'
,
parameters
)
self
.
assertIn
(
'timestamp'
,
parameters
)
parsed_date
=
from_timestamp
(
parameters
[
'timestamp'
])
parsed_date
=
from_timestamp
(
parameters
[
'timestamp'
])
self
.
assert
True
(
parsed_date
<
datetime
.
datetime
.
now
(
pytz
.
UTC
))
self
.
assert
Less
(
parsed_date
,
datetime
.
datetime
.
now
(
pytz
.
UTC
))
# Validate course information
# Validate course information
self
.
assertEqual
(
parameters
[
'course_org'
],
self
.
course_key
.
org
)
self
.
assertEqual
(
parameters
[
'course_org'
],
self
.
course_key
.
org
)
...
...
openedx/core/djangoapps/user_api/accounts/tests/test_api.py
View file @
9f89112e
...
@@ -80,7 +80,7 @@ class TestAccountApi(UserSettingsEventTestMixin, TestCase):
...
@@ -80,7 +80,7 @@ class TestAccountApi(UserSettingsEventTestMixin, TestCase):
# With default configuration settings, email is not shared with other (non-staff) users.
# With default configuration settings, email is not shared with other (non-staff) users.
account_settings
=
get_account_settings
(
self
.
default_request
,
self
.
different_user
.
username
)
account_settings
=
get_account_settings
(
self
.
default_request
,
self
.
different_user
.
username
)
self
.
assert
False
(
"email"
in
account_settings
)
self
.
assert
NotIn
(
"email"
,
account_settings
)
account_settings
=
get_account_settings
(
account_settings
=
get_account_settings
(
self
.
default_request
,
self
.
default_request
,
...
...
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