Skip to content

Consolidate duplicate and nested imports in test files#45

Merged
RobertBlackhart merged 2 commits intomainfrom
copilot/fix-duplicate-module-imports
Apr 17, 2026
Merged

Consolidate duplicate and nested imports in test files#45
RobertBlackhart merged 2 commits intomainfrom
copilot/fix-duplicate-module-imports

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 17, 2026

Several test modules imported the same modules multiple times, often inline within test function bodies rather than at the top of the file. This change hoists all imports to the module top and deduplicates them.

Changes

  • tests/test_commands/test_builtin_commands.py: hoisted curses and ReclineCommandError; removed 8 inline import recline, 2 inline ReclineCommandError, and 2 inline import curses.
  • tests/test_commands/test_async_command.py: hoisted os, sys, termios, threading, time, and the async_command symbols (CommandBackgrounded, CommandCancelled, set_terminal_echo); removed the corresponding inline duplicates.
  • tests/test_repl/test_shell.py: hoisted readline, sys, typing.Annotated, ReclineCommandError, builtin_commands as bc, CommandCancelled, CLICommand, OutputFormatter, and _split_unquoted; removed ~17 inline duplicates (notably 8× import builtins and 3× _split_unquoted).

Net effect: ~93 lines removed, ~23 added; no behavioral changes.

Example

Before:

def test_fg_no_jobs(monkeypatch):
    import recline
    from recline.commands import ReclineCommandError
    monkeypatch.setattr(recline, "JOBS", {})
    ...

After (imports already at top of file):

def test_fg_no_jobs(monkeypatch):
    monkeypatch.setattr(recline, "JOBS", {})
    ...
Original prompt

In the test files, there are many instances of the same module being imported multiple times, and often not at the top of the module. Fix this

Created from VS Code.

Agent-Logs-Url: https://github.com/NetApp/recline/sessions/7a2eaa6c-36b6-4202-a8a1-aae1977a52f9

Co-authored-by: RobertBlackhart <5414318+RobertBlackhart@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix multiple instances of module imports in test files Consolidate duplicate and nested imports in test files Apr 17, 2026
Copilot AI requested a review from RobertBlackhart April 17, 2026 17:39
@RobertBlackhart RobertBlackhart marked this pull request as ready for review April 17, 2026 17:42
@RobertBlackhart RobertBlackhart merged commit 5074542 into main Apr 17, 2026
9 checks passed
@RobertBlackhart RobertBlackhart deleted the copilot/fix-duplicate-module-imports branch April 17, 2026 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants