#26795: Factor out a "get_changes" method in tests.migrations.test_autodetector
--------------------------------------+------------------------------------
Reporter: akki | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Migrations | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by timgraham):
* component: Testing framework => Migrations
* stage: Unreviewed => Accepted
Old description:
> Recently, while working in
> [https://github.com/django/django/blob/c2e62fd1aed093c4d9ff84e3d86e6a85c8aa1917/tests/migrations/test_autodetector.py
> django.tests.migrations.test_autodetector] I noticed that the following
> code is getting repeated approx 100 times:
>
> {{{
> #!python
>
> 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:
> {{{
> #!python
>
> def get_changes(self, before_states, after_states):
> before = self.make_project_state([self.author_name])
> after = self.make_project_state([self.author_name_longer])
> autodetector = MigrationAutodetector(before, after)
> return autodetector._detect_changes()
>
> }}}
New description:
Recently, while working in
[https://github.com/django/django/blob/c2e62fd1aed093c4d9ff84e3d86e6a85c8aa1917/tests/migrations/test_autodetector.py
django.tests.migrations.test_autodetector] I noticed that the following
code is getting repeated approx 100 times:
{{{
#!python
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:
{{{
#!python
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()
}}}
--
--
Ticket URL: <https://code.djangoproject.com/ticket/26795#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/062.537e87c1d576d1d21f919287b9d05670%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.