Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#26795 closed Cleanup/optimization (fixed)

Factor out a "get_changes" method in tests.migrations.test_autodetector

Reported by: Akshesh Doshi Owned by: Akshesh Doshi
Component: Migrations Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description (last modified by Tim Graham)

Recently, while working in django.tests.migrations.test_autodetector I noticed that the following code is getting repeated approx 100 times:


    before = self.make_project_state([self.author_name])
    after = self.make_project_state([self.author_name_longer])
    autodetector = MigrationAutodetector(before, after)
    changes = autodetector._detect_changes()

I think it can be used as a simple method of the class cutting down a large chunk of code. Something like:

    def get_changes(self, before_states, after_states):
        before = self.make_project_state(before_states)
        after = self.make_project_state(after_states)
        autodetector = MigrationAutodetector(before, after)
        return autodetector._detect_changes()

Change History (7)

comment:1 by Akshesh Doshi, 9 years ago

Easy pickings: set

comment:2 by Akshesh Doshi, 9 years ago

Description: modified (diff)

comment:3 by Tim Graham, 9 years ago

Component: Testing frameworkMigrations
Description: modified (diff)
Summary: Refactor code in tests.migrations.test_autodetectorFactor out a "get_changes" method in tests.migrations.test_autodetector
Triage Stage: UnreviewedAccepted

comment:4 by Akshesh Doshi, 9 years ago

Owner: changed from nobody to Akshesh Doshi
Status: newassigned

comment:5 by Tim Graham, 9 years ago

Has patch: set
Triage Stage: AcceptedReady for checkin

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

Resolution: fixed
Status: assignedclosed

In ca77b509:

Fixed #26795 -- Factored out get_changes() in test_autodetector.py.

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

In 7f249e73:

[1.10.x] Fixed #26795 -- Factored out get_changes() in test_autodetector.py.

Backport of ca77b509059831b055a3b735ff77e042f8e1c0eb from master

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