Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove all ANSI codes from buf #302

Merged
merged 1 commit into from
Oct 21, 2023
Merged

Conversation

denisbondar
Copy link
Contributor

@denisbondar denisbondar commented Oct 21, 2023

Description

As discussed in the discussion #301, these regular expression modifications allow all possible combinations of ANSI codes to be removed from the buffer probably.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

The following unit test was augmented with two parameters:

@pytest.mark.parametrize(
    "buf, expected",
    (
        (
            b"[[email protected]: \x1b[1m/\x1b[0;0m]$",
            b"[[email protected]: /]$",
        ),
        (
            b"VeryLong\x1bECommand",
            b"VeryLongCommand",
        ),
        (
            b"command-prompt# \x1b7",
            b"command-prompt# ",
        ),
        (
            b"\x1b[7mCTRL+C\x1b[0m \x1b[7mESC\x1b[0m \x1b[7mq\x1b[0m Quit \x1b[7mSPACE\x1b[0m \x1b[7mn\x1b[0m Next Page \x1b[7mENTER\x1b[0m Next Entry \x1b[7ma\x1b[0m All\x1b[1A\x1b[59C\x1b[27m",
            b"CTRL+C ESC q Quit SPACE n Next Page ENTER Next Entry a All",
        ),
    ),
)
def test_strip_ansi(base_channel, buf: bytes, expected: bytes):
    actual_strip_ansi_output = base_channel._strip_ansi(buf=buf)
    assert actual_strip_ansi_output == expected

Regarding the successful execution of all unit tests, some tests that depend on the presence of an SSH server on the host failed as expected. I mean tests using socket_transport. I also wrote about it in the discussion #301.

Checklist:

  • My code follows the style guidelines of this project (no GitHub actions complaints! run make lint before
    committing!)
  • I have commented my code, pydocstyle and darglint are happy, docstrings are in google docstring format, and all
    docstrings include a summary, args, returns and raises fields (even if N/A)
  • I have added tests that prove my fix is effective or that my feature works, if adding "functional" tests please
    note if there are any considerations for the vrnetlab setup
  • New and existing unit tests pass locally with my changes

@codecov
Copy link

codecov bot commented Oct 21, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Files Coverage Δ
scrapli/channel/base_channel.py 98.33% <100.00%> (ø)

📢 Thoughts on this report? Let us know!.

@carlmontanari
Copy link
Owner

LGTM, thanks a bunch @denisbondar !!

@carlmontanari carlmontanari merged commit d0eb38b into carlmontanari:main Oct 21, 2023
14 checks passed
@denisbondar
Copy link
Contributor Author

LGTM, thanks a bunch @denisbondar !!

Thank you so much for continuing to support the project!

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