mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	Refs #34657 -- Made assertInHTML() use unparsed needle in error messages.
This commit is contained in:
		
				
					committed by
					
						 Mariusz Felisiak
						Mariusz Felisiak
					
				
			
			
				
	
			
			
			
						parent
						
							6ad0dbc8d9
						
					
				
				
					commit
					e99c7d8847
				
			
							
								
								
									
										1
									
								
								AUTHORS
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								AUTHORS
									
									
									
									
									
								
							| @@ -196,6 +196,7 @@ answer newbie questions, and generally made Django that much better: | ||||
|     charly.wilhelm@gmail.com | ||||
|     Chason Chaffin <chason@gmail.com> | ||||
|     Cheng Zhang | ||||
|     Chinmoy Chakraborty <chinmoy12c@gmail.com> | ||||
|     Chris Adams | ||||
|     Chris Beaven <smileychris@gmail.com> | ||||
|     Chris Bennett <chrisrbennett@yahoo.com> | ||||
|   | ||||
| @@ -873,13 +873,13 @@ class SimpleTestCase(unittest.TestCase): | ||||
|             self.fail(self._formatMessage(msg, standardMsg)) | ||||
|  | ||||
|     def assertInHTML(self, needle, haystack, count=None, msg_prefix=""): | ||||
|         needle = assert_and_parse_html( | ||||
|         parsed_needle = assert_and_parse_html( | ||||
|             self, needle, None, "First argument is not valid HTML:" | ||||
|         ) | ||||
|         haystack = assert_and_parse_html( | ||||
|         parsed_haystack = assert_and_parse_html( | ||||
|             self, haystack, None, "Second argument is not valid HTML:" | ||||
|         ) | ||||
|         real_count = haystack.count(needle) | ||||
|         real_count = parsed_haystack.count(parsed_needle) | ||||
|         if count is not None: | ||||
|             self.assertEqual( | ||||
|                 real_count, | ||||
|   | ||||
| @@ -983,6 +983,13 @@ class HTMLEqualTests(SimpleTestCase): | ||||
|         ) | ||||
|  | ||||
|  | ||||
| class InHTMLTests(SimpleTestCase): | ||||
|     def test_needle_msg(self): | ||||
|         msg = "False is not true : Couldn't find '<b>Hello</b>' in response" | ||||
|         with self.assertRaisesMessage(AssertionError, msg): | ||||
|             self.assertInHTML("<b>Hello</b>", "<p>Test</p>") | ||||
|  | ||||
|  | ||||
| class JSONEqualTests(SimpleTestCase): | ||||
|     def test_simple_equal(self): | ||||
|         json1 = '{"attr1": "foo", "attr2":"baz"}' | ||||
|   | ||||
		Reference in New Issue
	
	Block a user