rope icon indicating copy to clipboard operation
rope copied to clipboard

movetest: add test_moving_modules_lazy_import

Open SomeoneSerge opened this issue 1 year ago • 3 comments

Adds a failing test case for https://github.com/python-rope/rope/issues/731:

>       self.assertEqual(expected, self.mod1.read())
E       AssertionError: 'def import_later():\n    import pkg2.pkg3.pkg4.mod4' != 'import pkg2.pkg3.pkg4.mod4\ndef import_la[34 chars]mod4'
E       + import pkg2.pkg3.pkg4.mod4
E         def import_later():
E             import pkg2.pkg3.pkg4.mod4

ropetest/refactor/movetest.py:614: AssertionError
================================================================================================= warnings summary =================================================================================================
ropetest/refactor/movetest.py: 75 warnings
  /home/ss/Sources/rope/rope/base/project.py:229: DeprecationWarning: Delete once deprecated functions are gone
    self._init_source_folders()

Description

Please include a summary of the change and which issue is fixed.

Related: https://github.com/python-rope/rope/issues/731 (only partial fix, the extra import is still added)

Checklist (delete if not relevant):

  • [x] I have added tests that prove my fix is effective or that my feature works
  • [ ] I have updated CHANGELOG.md

SomeoneSerge avatar Nov 08 '23 14:11 SomeoneSerge

I observed some issues with "lazy" from-import statements where the module names sometimes wouldn't get updated. Summarized in the last test I pushed:

E       AssertionError: 'def import_later():\n    from pkg2.pkg3.p[77 chars]hing' != 'import pkg2.pkg3.pkg4.mod4\ndef import_la[109 chars]hing'                                                                     
E       + import pkg2.pkg3.pkg4.mod4                                                                                                                                                                                
E         def import_later():
E       -     from pkg2.pkg3.pkg4 import mod4
E       ?             -----------
E       +     from pkg import mod4
E             from pkg2.pkg3.pkg4.mod4 import thing
E         
E       -     mod4
E       +     pkg2.pkg3.pkg4.mod4
E             thing

ropetest/refactor/movetest.py:639: AssertionError

Where the task was to move pkg.mod4 to pkg2.pkg3.pkg4.mod4

SomeoneSerge avatar Nov 18 '23 05:11 SomeoneSerge

I can rebase, shall I?

SomeoneSerge avatar Jan 11 '24 04:01 SomeoneSerge

Hi @SomeoneSerge, we usually use a merge-based workflow, so a rebase is not usually necessary and I don't usually do a rebase before merging. But if the PR have too many re-merges with master or there are lots of unnecessary intermediate commits that isn't valuable to keep then a rebase may be sensible. Basically, you can and should use your own discretion whether or not to rebase.

lieryan avatar Jan 11 '24 17:01 lieryan