#26795: Refactor code in tests.migrations.test_autodetector
-------------------------------------+-------------------------------------
     Reporter:  akki                 |                    Owner:  nobody
         Type:                       |                   Status:  new
  Cleanup/optimization               |
    Component:  Testing framework    |                  Version:  master
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  1                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Description changed by akki:

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([self.author_name])
         after = self.make_project_state([self.author_name_longer])
         autodetector = MigrationAutodetector(before, after)
         return autodetector._detect_changes()

 }}}

--

--
Ticket URL: <https://code.djangoproject.com/ticket/26795#comment:2>
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.016ae45dfc7469307debc4f19028af7b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to