Opened 17 years ago
Closed 11 years ago
#5419 closed New feature (wontfix)
Add a model fuzz testing method to the test framework
Reported by: | Adrian Holovaty | Owned by: | Kevin Kubasik |
---|---|---|---|
Component: | Testing framework | Version: | dev |
Severity: | Normal | Keywords: | feature |
Cc: | d1fffuz0r@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Fuzz testing is when random, crazy data is thrown at some code to make sure it can handle crazy input. The Django test system should provide an assertModelPassesFuzzTest()
method (or pick a better name), which would take a model class as its argument and do the following:
- Insert a bunch of random data, including non-ASCII Unicode data, into a model instance and make sure the instance's
__unicode__()
doesn't throwUnicodeEncodeError
orUnicodeDecodeError
. - Call every custom model method that doesn't have
alters_data=True
(or maybe include those, too?) and make sure nothing silly happens. (In this case, it will be hard to determine what "silly" means, without some hints from the model method as to its expected output.)
Attachments (3)
Change History (16)
comment:1 by , 17 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 17 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:3 by , 17 years ago
Owner: | changed from | to
---|---|
Status: | assigned → new |
by , 17 years ago
by , 17 years ago
Attachment: | fuzz-docs.diff added |
---|
comment:4 by , 17 years ago
Has patch: | set |
---|
The attached patch (plus documentation) introduces two new assertions:
- assertModelUnicodePassesFuzzTest
- assertFunctionPassesFuzzTest
The first of these, assertModelUnicodePassesFuzzTest, assigns random unicode data to each of an instance of the model's fields and checks that calling the instance's unicode method doesn't raise a UnicodeError
I couldn't see how it would be possible to have an assertModelPassesFuzzTest (as Adrian suggested) that calls each of a models methods, as it would be very awkward to specify, for each method, valid argument types, response types and exceptions. Instead I have created assertFunctionPassesFuzzTest that allows you to call each method individually specifying valid inputs and outputs.
comment:5 by , 17 years ago
Keywords: | feature added |
---|
comment:6 by , 16 years ago
Owner: | changed from | to
---|
comment:7 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → New feature |
comment:8 by , 14 years ago
Easy pickings: | unset |
---|---|
Needs tests: | set |
comment:10 by , 12 years ago
Unicode-related problems and badly written unicode methods are less common than they used to be 5 years ago. I haven't encountered this class of problems frequently.
Given the lack of activity here, I suggest to abandon this ticket.
comment:11 by , 12 years ago
Cc: | added |
---|
Interesting feature. I want try to upgrade this patch for current version and to make tests for it.
by , 12 years ago
Attachment: | fuzz.2.patch added |
---|
comment:12 by , 12 years ago
Needs tests: | unset |
---|
patch has been updated and tested in python 2.7.3/3.3.0. also added some tests.
comment:13 by , 11 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
Agreed with Aymeric's comment from 19 months ago, it doesn't seem like this is something that Django needs to provide.
Last change was me, sorry.
Adrian raised this ticket, so I assume it is correct to set to "Accepted".