[Django] #32003: tests: Signature of mocked User.has_perm() different from real implementation

7 views
Skip to first unread message

Django

unread,
Sep 14, 2020, 5:35:22 AM9/14/20
to django-...@googlegroups.com
#32003: tests: Signature of mocked User.has_perm() different from real
implementation
---------------------------------------------+------------------------
Reporter: Alexander Todorov | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 3.1
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 1
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
---------------------------------------------+------------------------
In particular all of the mocked methods receive 2 arguments: self, perm
while the real one in PermissionsMixin also has a keyword agument called
obj.

This gets in the way of trying to work on passing the object to
user.has_perm() in ModelAdmin because it will cause the tests to fail
artificially.

I have a commit at
https://github.com/atodorov/django/commits/fix_mocked_has_perm which
doesn't fail locally and seems to do the job.
Let me know if you want me to open a pull request.

--
Ticket URL: <https://code.djangoproject.com/ticket/32003>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 14, 2020, 5:46:26 AM9/14/20
to django-...@googlegroups.com
#32003: Signature of mocked has_perm() methods is outdated.
--------------------------------------+------------------------------------

Reporter: Alexander Todorov | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Testing framework | Version: 3.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by felixxm):

* type: Uncategorized => Cleanup/optimization
* has_patch: 1 => 0
* component: Uncategorized => Testing framework
* stage: Unreviewed => Accepted


Comment:

Patch is welcome.

--
Ticket URL: <https://code.djangoproject.com/ticket/32003#comment:1>

Django

unread,
Sep 14, 2020, 6:20:17 AM9/14/20
to django-...@googlegroups.com
#32003: Signature of mocked has_perm() methods is outdated.
-------------------------------------+-------------------------------------
Reporter: Alexander Todorov | Owner: Alexander
Type: | Todorov
Cleanup/optimization | Status: assigned

Component: Testing framework | Version: 3.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* owner: nobody => Alexander Todorov
* status: new => assigned
* has_patch: 0 => 1
* stage: Accepted => Ready for checkin


Comment:

[https://github.com/django/django/pull/13419 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/32003#comment:2>

Django

unread,
Sep 14, 2020, 6:28:57 AM9/14/20
to django-...@googlegroups.com
#32003: Signature of mocked has_perm() methods is outdated.
-------------------------------------+-------------------------------------
Reporter: Alexander Todorov | Owner: Alexander
Type: | Todorov
Cleanup/optimization | Status: closed

Component: Testing framework | Version: 3.1
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by GitHub <noreply@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"5fab16392fc00702a5d0288378892ec48fe67dc6" 5fab1639]:
{{{
#!CommitTicketReference repository=""
revision="5fab16392fc00702a5d0288378892ec48fe67dc6"
Fixed #32003 -- Added obj argument to has_perm() methods in tests.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/32003#comment:3>

Reply all
Reply to author
Forward
0 new messages