micropython/tests/basics/string_splitlines.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

38 lines
1010 B
Python
Raw Normal View History

# test string.splitlines() method
2015-04-03 22:09:23 +01:00
try:
str.splitlines
except:
print("SKIP")
raise SystemExit
# test \n as newline
2015-04-03 22:09:23 +01:00
print("foo\nbar".splitlines())
print("foo\nbar\n".splitlines())
print("foo and\nbar\n".splitlines())
print("foo\nbar\n\n".splitlines())
print("foo\n\nbar\n\n".splitlines())
print("\nfoo\nbar\n".splitlines())
# test \r as newline
print("foo\rbar\r".splitlines())
print("\rfoo and\r\rbar\r".splitlines())
# test \r\n as newline
print("foo\r\nbar\r\n".splitlines())
print("\r\nfoo and\r\n\r\nbar\r\n".splitlines())
# test keepends arg
2015-04-03 22:09:23 +01:00
print("foo\nbar".splitlines(True))
print("foo\nbar\n".splitlines(True))
print("foo\nbar\n\n".splitlines(True))
print("foo\rbar".splitlines(keepends=True))
print("foo\rbar\r\r".splitlines(keepends=True))
print("foo\r\nbar".splitlines(keepends=True))
print("foo\r\nbar\r\n\r\n".splitlines(keepends=True))
# test splitting bytes objects
print(b"foo\nbar".splitlines())
print(b"foo\nbar\n".splitlines())
print(b"foo\r\nbar\r\n\r\n".splitlines(True))