Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
edit center and expandtabs tests
  • Loading branch information
farah-salama committed Apr 21, 2024
commit f947a3d16f498a013eed76ddea14524ba8ae70a5
35 changes: 21 additions & 14 deletions integration_tests/test_str_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,22 +473,29 @@ def is_numeric():
assert "ab2%3".isnumeric() == False

def center():
Copy link
Contributor

@kmr-srbh kmr-srbh Apr 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current implementation supports runtime strings. Please add tests for them. By runtime strings, I mean a string stored in a variable. You can have a look at how is_upper() is tested.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@farah-salama please update the test references also.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please rebuild and update the test references again?

assert "test".center(8,'*') == "**test**"
assert "test".center(11) == " test "
assert "test".center(2) == "test"
assert "test".center(4) == "test"
assert "test".center(9,'/') == "///test//"
s: str = "test"
assert s.center(8,'*') == "**test**"
assert s.center(11) == " test "
assert s.center(2) == "test"
assert s.center(4) == "test"
assert s.center(9,'/') == "///test//"

def expandtabs():
assert '01\t012\t0123\t01234'.expandtabs() == "01 012 0123 01234"
assert '01\t012\t0123\t01234'.expandtabs(4) == "01 012 0123 01234"
assert '01\t012\t0123\t01234'.expandtabs(-1) == "01012012301234"
assert '\t'.expandtabs() == " "
assert ''.expandtabs() == ""
assert '\tThis\ris\na\ttest'.expandtabs(4) == " This\ris\na test"
assert '\t\t\t'.expandtabs(2) == " "
assert 'test\ttest'.expandtabs(0) == "testtest"
assert 'test\ttest'.expandtabs(-5) == "testtest"
s: str = '01\t012\t0123\t01234'
assert s.expandtabs() == "01 012 0123 01234"
assert s.expandtabs(4) == "01 012 0123 01234"
assert s.expandtabs(-1) == "01012012301234"
s = '\t'
assert s.expandtabs() == " "
s = ''
assert s.expandtabs() == ""
s = '\tThis\ris\na\ttest'
assert s.expandtabs(4) == " This\ris\na test"
s = '\t\t\t'
assert s.expandtabs(2) == " "
s = 'test\ttest'
assert s.expandtabs(0) == "testtest"
assert s.expandtabs(-5) == "testtest"

def check():
capitalize()
Expand Down