Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#20316 closed Cleanup/optimization (fixed)

TestCase will let code rollback and commit without warning

Reported by: uberj@… Owned by: nobody
Component: Documentation Version: dev
Severity: Normal Keywords: testcase transactions
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

The docs for TransactionTestCase say TestCase "prevents the code under test from issuing any commit or rollback operations on the database". Code running in a TestCase that uses commit or rollback will still appear to work. Of course, those functions don't do anything, they have been replaced by a nop function that silently does nothing -- see here.

The 'silently' part does not help a user that is using TestCase but should be using TransactionTestCase.

Change History (7)

comment:1 by uberj@…, 11 years ago

In a perfect world, I would like to see at least one of the following happen:

  • nop raise an exception warning the user that they should be using TransactionTestCase
  • A print statement warning the user
  • The docs on TransactionTestCase updated to not use the word 'prevents', and mention something about how functions like commit and rollback are essentially callable nops when used in a TestCase.

comment:2 by Simon Charette, 11 years ago

Component: Testing frameworkDocumentation
Easy pickings: set
Keywords: testcase transactions added
Needs documentation: set
Type: UncategorizedCleanup/optimization
Version: 1.4master

Unfortunately first and second options are no-go since there's no reliable way to differentiate implicit from explicit commit and rollback calls.

i.e. You'd like explicit transaction.commit call to raise an exception or a warning but not the implicit calls from Model().save().

It would also be highly backward incompatible.

Third option seems reasonable, a documentation patch is welcome!

comment:3 by Tim Graham, 11 years ago

Triage Stage: UnreviewedAccepted

comment:5 by Tim Graham, 11 years ago

Has patch: set

comment:6 by Tim Graham <timograham@…>, 11 years ago

Resolution: fixed
Status: newclosed

In dffdca1109a2111f104f2419d081c0f971537fec:

Fixed #20316 - Clarified transaction behavior of TestCase.

Thanks uberj@ for the report and lolek09 for the patch.

comment:7 by Tim Graham <timograham@…>, 11 years ago

In cd15a51c3eb2918107814e7c42533ebef982a431:

[1.5.x] Fixed #20316 - Clarified transaction behavior of TestCase.

Thanks uberj@ for the report and lolek09 for the patch.

Backport of dffdca1109 from master

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