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 leading and trailing whitespace #1058

Merged
merged 2 commits into from
Apr 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions securedrop_client/gui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ def __init__(
self.elided = True if self.text() != text else False

def setText(self, text: str) -> None:
text = text.strip()
self.setTextFormat(Qt.PlainText)
elided_text = self.get_elided_text(text)
self.elided = True if elided_text != text else False
Expand Down
6 changes: 6 additions & 0 deletions tests/gui/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,9 @@ def test_SecureQLabel_get_elided_text_only_returns_oneline_elided(mocker):
def test_SecureQLabel_quotes_not_escaped_for_readability():
sl = SecureQLabel("'hello'")
assert sl.text() == "'hello'"


def test_SecureQLabel_trims_leading_and_trailing_whitespace():
string_with_whitespace = ('\n \n this is a string with leading and trailing whitespace \n')
sl = SecureQLabel(string_with_whitespace)
assert sl.text() == "this is a string with leading and trailing whitespace"