Skip to content

Commit

Permalink
Merge 8c91106 into 7dd6046
Browse files Browse the repository at this point in the history
  • Loading branch information
singleton11 committed Dec 29, 2017
2 parents 7dd6046 + 8c91106 commit 7ee85dc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion test_plus/test.py
Expand Up @@ -417,10 +417,11 @@ def get(self, cls, *args, **kwargs):
Calls cls.get() method after instantiating view class.
Renders view templates and sets context if appropriate.
"""
data = kwargs.pop('data', None)
instance = self.get_instance(cls, *args, **kwargs)
if not instance.request:
# Use a basic request
instance.request = RequestFactory().get('/')
instance.request = RequestFactory().get('/', data)
self.last_response = self.get_response(instance.request, instance.get)
self.context = self.last_response.context
return self.last_response
Expand Down
3 changes: 3 additions & 0 deletions test_project/test_app/tests.py
Expand Up @@ -433,10 +433,13 @@ def test_get_request_attributes(self):
# add custom attribute
request.some_data = 5

data = {'some_data_key': 'some_data_value'}

self.get(
CBDataView,
request=request,
pk=self.data.pk,
data=data,
)
# view copies `request.some_data` into context if present
self.assertContext('some_data', 5)
Expand Down

0 comments on commit 7ee85dc

Please sign in to comment.