Opened 5 years ago

Closed 5 years ago

Last modified 4 years ago

#13636 closed (fixed)

Change fixture doctests to unit tests

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

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 ericholscher 5 years ago.
nicer-migration-patch.diff (50.3 KB) - added by ericholscher 5 years ago.
A slightly updated patch.
migrate-doctests-to-unittests.diff (55.2 KB) - added by ericholscher 5 years ago.
Updated to pass around streams for stdout and stderr
13636-r13318.diff (59.7 KB) - added by russellm 5 years ago.
Updated fix, mostly formatting changes (this time with the missing file)

Download all attachments as: .zip

Change History (8)

Changed 5 years ago by ericholscher

Changed 5 years ago by ericholscher

A slightly updated patch.

Changed 5 years ago by ericholscher

Updated to pass around streams for stdout and stderr

comment:1 Changed 5 years ago by ericholscher

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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 Changed 5 years ago by russellm

  • Patch needs improvement set
  • Triage Stage changed from Unreviewed to Accepted

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.

Changed 5 years ago by russellm

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

comment:3 Changed 5 years ago by russellm

  • Resolution set to fixed
  • Status changed from new to closed

(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 Changed 4 years ago by jacob

  • milestone 1.3 deleted

Milestone 1.3 deleted

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