#29885 closed Bug (invalid)
mock called never gets set after upgrade to 2.1
Reported by: | Julz | Owned by: | nobody |
---|---|---|---|
Component: | Testing framework | Version: | 2.1 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
after upgrading from 2.0.9 to 2.1.2 we have a problem with a test like this:
@patch.object(SomeModelAdmin, 'action_to_mock') def test_admin_action_is_triggered(self, action_mock): url = reverse('admin:some_model_changelist') data = {'action': 'action_to_mock', '_selected_action': [1, 2]} self.client.post(url, data) self.assertTrue(action_mock.called)
on versions <2.1 it works fine. called is set to True and the call_count increases.
I can't find anything in the changelogs so I assume it's a bug
Change History (2)
comment:1 by , 6 years ago
Description: | modified (diff) |
---|
comment:2 by , 6 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
This was probably caused by #29419.
Which is mentioned in the release notes
https://docs.djangoproject.com/en/2.1/releases/2.1/#minor-features
https://docs.djangoproject.com/en/2.1/ref/contrib/admin/actions/#setting-permissions-for-actions
Since you are mocking the function you must make sure it doesn't have an
allowed_permissions
attributehttps://github.com/django/django/commit/958c7b301ead79974db8edd5b9c6588a10a28ae7#diff-3c42de3e53aba87b32c494f995a728dfR878
A simple
delattr(action_mock, 'allowed_permissions')
before theself.client.post
should do.Please use support channels before assuming something is a bug, this tracker is used to track confirmed issues and feature requests and isn't a second tier support channel. (See TicketClosingReasons/UseSupportChannels)