To assert if a string is or is not a substring of another, you should use assertIn
and assertNotIn
:
# Passes
self.assertIn('bcd', 'abcde')
# AssertionError: 'bcd' unexpectedly found in 'abcde'
self.assertNotIn('bcd', 'abcde')
These are new since Python 2.7 and Python 3.1