MCPcopy Index your code
hub / github.com/python/cpython / testAssertNotEndsWith

Method testAssertNotEndsWith

Lib/test/test_unittest/test_case.py:2143–2186  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2141 self.assertIn('ababahalamaha', str(cm.exception))
2142
2143 def testAssertNotEndsWith(self):
2144 self.assertNotEndsWith('ababahalamaha', 'ababa')
2145 self.assertNotEndsWith('ababahalamaha', ('x', 'ababa', 'y'))
2146 self.assertNotEndsWith(UserString('ababahalamaha'), 'ababa')
2147 self.assertNotEndsWith(UserString('ababahalamaha'), ('x', 'ababa', 'y'))
2148 self.assertNotEndsWith(bytearray(b'ababahalamaha'), b'ababa')
2149 self.assertNotEndsWith(bytearray(b'ababahalamaha'), (b'x', b'ababa', b'y'))
2150 self.assertNotEndsWith(b'ababahalamaha', bytearray(b'ababa'))
2151 self.assertNotEndsWith(b'ababahalamaha',
2152 (bytearray(b'x'), bytearray(b'ababa'), bytearray(b'y')))
2153
2154 with self.assertRaises(self.failureException) as cm:
2155 self.assertNotEndsWith('ababahalamaha', 'amaha')
2156 self.assertEqual(str(cm.exception),
2157 "'ababahalamaha' ends with 'amaha'")
2158 with self.assertRaises(self.failureException) as cm:
2159 self.assertNotEndsWith('ababahalamaha', ('x', 'amaha', 'y'))
2160 self.assertEqual(str(cm.exception),
2161 "'ababahalamaha' ends with 'amaha'")
2162
2163 with self.assertRaises(self.failureException) as cm:
2164 self.assertNotEndsWith(b'ababahalamaha', 'amaha')
2165 self.assertEqual(str(cm.exception), 'Expected str, not bytes')
2166 with self.assertRaises(self.failureException) as cm:
2167 self.assertNotEndsWith(b'ababahalamaha', ('ababa', 'amaha'))
2168 self.assertEqual(str(cm.exception), 'Expected str, not bytes')
2169 with self.assertRaises(self.failureException) as cm:
2170 self.assertNotEndsWith([], 'amaha')
2171 self.assertEqual(str(cm.exception), 'Expected str, not list')
2172 with self.assertRaises(self.failureException) as cm:
2173 self.assertNotEndsWith('ababahalamaha', b'amaha')
2174 self.assertEqual(str(cm.exception), 'Expected bytes, not str')
2175 with self.assertRaises(self.failureException) as cm:
2176 self.assertNotEndsWith('ababahalamaha', (b'ababa', b'amaha'))
2177 self.assertEqual(str(cm.exception), 'Expected bytes, not str')
2178 with self.assertRaises(TypeError):
2179 self.assertNotEndsWith('ababahalamaha', ord('a'))
2180
2181 with self.assertRaises(self.failureException) as cm:
2182 self.assertNotEndsWith('ababahalamaha', 'amaha', 'abracadabra')
2183 self.assertIn('ababahalamaha', str(cm.exception))
2184 with self.assertRaises(self.failureException) as cm:
2185 self.assertNotEndsWith('ababahalamaha', 'amaha', msg='abracadabra')
2186 self.assertIn('ababahalamaha', str(cm.exception))
2187
2188 def testDeprecatedFailMethods(self):
2189 """Test that the deprecated fail* methods get removed in 3.12"""

Callers

nothing calls this directly

Calls 6

UserStringClass · 0.90
strFunction · 0.85
assertNotEndsWithMethod · 0.80
assertInMethod · 0.80
assertRaisesMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected