Opened 5 years ago

Closed 5 years ago

#30358 closed Cleanup/optimization (fixed)

Remove redundant assertion from django/tests/forms_tests/tests/test_utils.py.

Reported by: Petru-Florin Mihancea Owned by: Krisjanis Vaiders
Component: Forms Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

While experimenting with a CodeSonar plugin we develop, we noticed a potential bug in file "django/tests/forms_tests/tests/test_utils.py" line 154 function test_error_dict_copy.

e_deepcopy = copy.deepcopy(e)
self.assertEqual(e, e_deepcopy)
self.assertEqual(e.as_data(), e_copy.as_data()) HERE

Shouldn't you get the data from e_deepcopy in that line (instead the data of e_copy)?

Thanks,
Petru-Florin Mihancea

Change History (5)

comment:1 by Mariusz Felisiak, 5 years ago

Easy pickings: set
Summary: Possible access to unintended variable in "django/tests/forms_tests/tests/test_utils.py" line 154Remove redundant assertion from django/tests/forms_tests/tests/test_utils.py.
Triage Stage: UnreviewedAccepted
Type: BugCleanup/optimization

Thanks for the report. With e_deepcopy assertion fails, because deepcopy() creates copies of ValidationError. IMO we should just remove this redundant assertion.

comment:2 by Krisjanis Vaiders, 5 years ago

Owner: changed from nobody to Krisjanis Vaiders
Status: newassigned

comment:4 by Mariusz Felisiak, 5 years ago

Triage Stage: AcceptedReady for checkin

comment:5 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

Resolution: fixed
Status: assignedclosed

In 79d3b90:

Fixed #30358 -- Removed redundant assertion in FormsUtilsTestCase.test_error_dict_copy().

Note: See TracTickets for help on using tickets.
Back to Top