# assertStartWith vs assertStartwith

**URL:** <https://discuss.python.org/t/assertstartwith-vs-assertstartwith/76701>\
**Category:** Core Development\
**Created:** [January 10, 2025, 2:05pm UTC](https://discuss.python.org/t/assertstartwith-vs-assertstartwith/76701 "2025-01-10T14:05:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![storchaka](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/storchaka/32/217_2.png) [@storchaka](https://discuss.python.org/u/storchaka)\
**Post date:** [January 10, 2025, 2:05pm UTC](https://discuss.python.org/t/assertstartwith-vs-assertstartwith/76701/1 "2025-01-10T14:05:49Z")

</div>

I am going to add several additional assertion methods for `unittest`.

> <https://github.com/python/cpython/issues/71339>
>
> BPO | \[27152\](https://bugs.python.org/issue27152)
> \--- | :---
> Nosy | @rhettinger,… @rbtcollins, @ezio-melotti, @bitdancer, @voidspace, @serhiy-storchaka, @PythonCHB
> Files | \<li\>\[extra\_assertions.patch\](https://bugs.python.org/file43047/extra\_assertions.patch "Uploaded as text/plain at 2016-05-29.15:24:52 by @serhiy-storchaka")\</li\>
> 
> \<sup\>\*Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.\*\</sup\>
> 
> \<details\>\<summary\>Show more details\</summary\>\<p\>
> 
> GitHub fields:
> \`\`\`python
> assignee = None
> closed\_at = None
> created\_at = \<Date 2016-05-29.15:25:19.795\>
> labels = \['type-feature', 'tests'\]
> title = 'Additional assert methods for unittest'
> updated\_at = \<Date 2016-06-22.14:03:21.198\>
> user = 'https://github.com/serhiy-storchaka'
> \`\`\`
> 
> bugs.python.org fields:
> \`\`\`python
> activity = \<Date 2016-06-22.14:03:21.198\>
> actor = 'r.david.murray'
> assignee = 'none'
> closed = False
> closed\_date = None
> closer = None
> components = \['Tests'\]
> creation = \<Date 2016-05-29.15:25:19.795\>
> creator = 'serhiy.storchaka'
> dependencies = \[\]
> files = \['43047'\]
> hgrepos = \[\]
> issue\_num = 27152
> keywords = \['patch'\]
> message\_count = 10.0
> messages = \['266600', '266601', '266620', '266627', '266675', '266682', '267175', '267185', '268877', '269074'\]
> nosy\_count = 8.0
> nosy\_names = \['rhettinger', 'rbcollins', 'ezio.melotti', 'r.david.murray', 'michael.foord', 'Pam.McANulty', 'serhiy.storchaka', 'ChrisBarker'\]
> pr\_nums = \[\]
> priority = 'normal'
> resolution = None
> stage = 'patch review'
> status = 'open'
> superseder = None
> type = 'enhancement'
> url = 'https://bugs.python.org/issue27152'
> versions = \['Python 3.6'\]
> \`\`\`
> 
> \</p\>\</details\>
> 
> 
> 
> \### Linked PRs
> \* gh-128707

This is an old issue, and such methods (`assertIsSubclass`, `assertHasAttr`, `assertEndsWith`) are already defined in several test files. The question is how to spell correctly some names. It seems that there are different opinions and my level of English does not allow me to make a qualified choice.

_Poll ([view on site](https://discuss.python.org/t/assertstartwith-vs-assertstartwith/76701/1))_

---

<div class="post-metadata">

**Author:** ![hugovk](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/hugovk/32/14505_2.png) [@hugovk](https://discuss.python.org/u/hugovk)\
**Post date:** [January 10, 2025, 2:26pm UTC](https://discuss.python.org/t/assertstartwith-vs-assertstartwith/76701/2 "2025-01-10T14:26:32Z")

</div>

I recommend `assertStartsWith()` and `assertEndsWith()`, both for readability and for accessibility – screen readers will have a better chance with the extra capitals and it helps people with dyslexia and cognitive disabilities.

It doesn’t really matter that `str.startswith` is all lower case, because we’re creating a new method name.

All the other [methods](https://docs.python.org/3/library/unittest.html#assert-methods) follow the same capitalisation rule.

For example, the one that checks checks `isinstance` is `assertIsInstance` and not `assertIsinstance`.

Here’s similar accessibility advice about hashtags:

> **[Make Your Hashtags Accessible](https://www.boia.org/blog/make-your-hashtags-accessible)**
>
> Make hashtags accessible to screen readers, people with cognitive or reading disabilities, or anyone who has trouble reading them by capitalizing the first letter of each word. Learn more here, brought to you by the Bureau of Internet Accessibility.

See also [Change environment variable style - #2 by hugovk](https://discuss.python.org/t/change-environment-variable-style/35180/2).

---

<div class="post-metadata">

**Author:** ![storchaka](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/storchaka/32/217_2.png) [@storchaka](https://discuss.python.org/u/storchaka)\
**Post date:** [January 20, 2025, 1:19pm UTC](https://discuss.python.org/t/assertstartwith-vs-assertstartwith/76701/3 "2025-01-20T13:19:24Z")

</div>

I do not see votes of @rhettinger and @bitdancer which supported `assertStartswith`, but even if they still support them, the support of `assertStartsWith` is overhelming. So this variant has been merged.

I also backported the new assertion methods as methods of `test.support.testcase.ExtraAssertions`. This will help with backporting. Now, if you backport tests that use these methods, you can simply add the `ExtraAssertions` mixing to the test class.
