8000 update starts_with() and ends_with() assertions to support lists · Issue #24 · assertpy/assertpy · GitHub
[go: up one dir, main page]

Skip to content

update starts_with() and ends_with() assertions to support lists #24

@saturnboy

Description

@saturnboy

Extend these assertions to support both lists and tuples (aka ordered collections), not just strings.

Currently starts_with() and ends_with() only support strings, like this:

assert_that('foo').starts_with('f')
assert_that('foo').ends_with('oo')

Add support for lists:

assert_that([1,2,3]).starts_with(1)
assert_that([1,2,3]).ends_with(3)

Add support for tuples:

assert_that((1,2,3)).starts_with(1)
assert_that((1,2,3)).ends_with(3)

Also, support multiple args (starts with the given sequence, or ends with the given sequence):

assert_that([1,2,3]).starts_with(1,2)
assert_that([1,2,3]).ends_with(2,3)
assert_that((1,2,3)).starts_with(1,2)
assert_that((1,2,3)).ends_with(2,3)

Lastly, we need to have a great error message for this failing case:

assert_that([1,2,3]).starts_with([1,2])

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0