Opened 6 years ago

Closed 4 years ago

#12191 closed Cleanup/optimization (duplicate)

It's not possible to run a specific test if it's not in models.py or tests.py (e.g. when using suites)

Reported by: dolapo Owned by: dolapo
Component: Testing framework Version: 1.1
Severity: Normal Keywords: testing test
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description (last modified by ramiro)

The simple django test runner looks for tests in either models.py or tests.py. This is unfortunate for large applications since tests.py in each app becomes rather large and unwieldy. Apps with a large number of tests can break out their tests further by creating a method called suite() that returns a TestSuite. This works for test separation but because the runner still looks for test cases in models.py or tests.py it is no longer possible to run an individual TestCase or TestCase.test_method .

Proposal:
In addition to supporting the ability to specify tests to run as:

  • app
  • app.TestCase
  • app.TestCase.test_method

also support:

  • app.module.TestCase.test_method
  • app.module.TestCase.*

I'm including a patch which adds this functionality.

Attachments (2)

tests_specify_module.diff (4.5 KB) - added by dolapo 6 years ago.
testpackage.diff (1.8 KB) - added by mapleoin 5 years ago.
documentation patch

Download all attachments as: .zip

Change History (7)

Changed 6 years ago by dolapo

comment:1 Changed 6 years ago by dolapo

  • Owner changed from nobody to dolapo
  • Status changed from new to assigned

Since I screwed up the formatting in the description, this patch adds to the simple test runner the ability to run tests as:

app.module.TestCase.test_method
app.module.TestCase.*

comment:2 Changed 5 years ago by mapleoin

This looks more like a documentation bug to me, you can replace tests.py with a tests python package and you can have as many submodules as you want in different files in that package as explained in the Python docs.

I'm attaching a documentation patch.

Changed 5 years ago by mapleoin

documentation patch

comment:3 Changed 5 years ago by ericholscher

  • Triage Stage changed from Unreviewed to Accepted

comment:4 Changed 4 years ago by mattmcc

  • Severity set to Normal
  • Type set to Cleanup/optimization

comment:5 Changed 4 years ago by ramiro

  • Description modified (diff)
  • Easy pickings unset
  • Resolution set to duplicate
  • Status changed from assigned to closed
  • UI/UX unset

Duplicate of #6712.

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