Opened 15 years ago

Closed 14 years ago

Last modified 13 years ago

#13636 closed (fixed)

Change fixture doctests to unit tests

Reported by: Eric Holscher Owned by: nobody
Component: Testing framework Version: dev
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

These have the most amount of flushing, which will slow down real test runs. I've gone ahead and done a good amount of this, it does touch management commands to have a return_output that you can pass into call_command, so it returns instead of prints for dumpdata and such.

Attachments (4)

fixtures-doctests-remove.diff (51.1 KB ) - added by Eric Holscher 15 years ago.
nicer-migration-patch.diff (50.3 KB ) - added by Eric Holscher 14 years ago.
A slightly updated patch.
migrate-doctests-to-unittests.diff (55.2 KB ) - added by Eric Holscher 14 years ago.
Updated to pass around streams for stdout and stderr
13636-r13318.diff (59.7 KB ) - added by Russell Keith-Magee 14 years ago.
Updated fix, mostly formatting changes (this time with the missing file)

Download all attachments as: .zip

Change History (8)

by Eric Holscher, 15 years ago

by Eric Holscher, 14 years ago

Attachment: nicer-migration-patch.diff added

A slightly updated patch.

by Eric Holscher, 14 years ago

Updated to pass around streams for stdout and stderr

comment:1 by Eric Holscher, 14 years ago

This is a basic patch that makes the tests pass. I'm not totally sold on the changes to the management commands -- feels like that should be using the new logging infrastructure. It should probably have a little bit of a wrapper that we can swap out the explicit stdout calls to logging.

This should probably also be 2 tickets -- but they are interconnected via a little yak shaving :)

comment:2 by Russell Keith-Magee, 14 years ago

Patch needs improvement: set
Triage Stage: UnreviewedAccepted

There is one test failure for this patch under MySQL:

======================================================================
FAIL: test_format_discovery (modeltests.fixtures.tests.FixtureTransactionTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/rkm/projects/django/hg/tests/modeltests/fixtures/tests.py", line 262, in test_format_discovery
    '<Article: Python program becomes self aware>'
  File "/Users/rkm/projects/django/live/django/test/testcases.py", line 470, in assertQuerysetEqual
    return self.assertEqual(map(transform, qs), values)
AssertionError: ['<Article: XML identified as leading cause of cancer>', '<Article: Time to reform copyright>', '<Article: Poker on TV is great!>', '<Article: Python program becomes self aware>'] != ['<Article: Time to reform copyright>', '<Article: Poker has no place on ESPN>', '<Article: Python program becomes self aware>']

The test in question was commented out under MySQL under the doctests; it's not immediately clear to me whether this is a test that should still be commented out, or whether the move to TransactionTestCase should overcome that problem and we've just revealed a previously unknown problem.

Also - given that this test introduces the stdout/stderr arguments, it would make sense to port the multiple-databases fixture loading test that currently does some jiggery-pokery to work around stdout handling.

by Russell Keith-Magee, 14 years ago

Attachment: 13636-r13318.diff added

Updated fix, mostly formatting changes (this time with the missing file)

comment:3 by Russell Keith-Magee, 14 years ago

Resolution: fixed
Status: newclosed

(In [13319]) Fixed #13636 -- Migrated fixtures tests to use unittests, eliminating another set of expensive flush calls. Thanks to Eric Holscher for the patch.

comment:4 by Jacob, 13 years ago

milestone: 1.3

Milestone 1.3 deleted

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