mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 21:51:50 +00:00 
			
		
		
		
	Issue #19030: fix new pydoc tests for --without-doc-strings
This commit is contained in:
		
							parent
							
								
									327dd732ce
								
							
						
					
					
						commit
						3f2f19230c
					
				
					 1 changed files with 22 additions and 5 deletions
				
			
		|  | @ -215,11 +215,9 @@ class B(builtins.object) | ||||||
| class DA(builtins.object) | class DA(builtins.object) | ||||||
|  |  Data descriptors defined here: |  |  Data descriptors defined here: | ||||||
|  |\x20\x20 |  |\x20\x20 | ||||||
|  |  __dict__ |  |  __dict__%s | ||||||
|  |      dictionary for instance variables (if defined) |  | ||||||
|  |\x20\x20 |  |\x20\x20 | ||||||
|  |  __weakref__ |  |  __weakref__%s | ||||||
|  |      list of weak references to the object (if defined) |  | ||||||
|  |\x20\x20 |  |\x20\x20 | ||||||
|  |  ham |  |  ham | ||||||
|  |\x20\x20 |  |\x20\x20 | ||||||
|  | @ -709,6 +707,10 @@ def test_keywords(self): | ||||||
|                          sorted(keyword.kwlist)) |                          sorted(keyword.kwlist)) | ||||||
| 
 | 
 | ||||||
| class PydocWithMetaClasses(unittest.TestCase): | class PydocWithMetaClasses(unittest.TestCase): | ||||||
|  |     @unittest.skipIf(sys.flags.optimize >= 2, | ||||||
|  |                      "Docstrings are omitted with -O2 and above") | ||||||
|  |     @unittest.skipIf(hasattr(sys, 'gettrace') and sys.gettrace(), | ||||||
|  |                      'trace function introduces __locals__ unexpectedly') | ||||||
|     def test_DynamicClassAttribute(self): |     def test_DynamicClassAttribute(self): | ||||||
|         class Meta(type): |         class Meta(type): | ||||||
|             def __getattr__(self, name): |             def __getattr__(self, name): | ||||||
|  | @ -719,15 +721,22 @@ class DA(metaclass=Meta): | ||||||
|             @types.DynamicClassAttribute |             @types.DynamicClassAttribute | ||||||
|             def ham(self): |             def ham(self): | ||||||
|                 return 'eggs' |                 return 'eggs' | ||||||
|  |         expected_text_data_docstrings = tuple('\n |      ' + s if s else '' | ||||||
|  |                                       for s in expected_data_docstrings) | ||||||
|         output = StringIO() |         output = StringIO() | ||||||
|         helper = pydoc.Helper(output=output) |         helper = pydoc.Helper(output=output) | ||||||
|         helper(DA) |         helper(DA) | ||||||
|         expected_text = expected_dynamicattribute_pattern % __name__ |         expected_text = expected_dynamicattribute_pattern % ( | ||||||
|  |                 (__name__,) + expected_text_data_docstrings[:2]) | ||||||
|         result = output.getvalue().strip() |         result = output.getvalue().strip() | ||||||
|         if result != expected_text: |         if result != expected_text: | ||||||
|             print_diffs(expected_text, result) |             print_diffs(expected_text, result) | ||||||
|             self.fail("outputs are not equal, see diff above") |             self.fail("outputs are not equal, see diff above") | ||||||
| 
 | 
 | ||||||
|  |     @unittest.skipIf(sys.flags.optimize >= 2, | ||||||
|  |                      "Docstrings are omitted with -O2 and above") | ||||||
|  |     @unittest.skipIf(hasattr(sys, 'gettrace') and sys.gettrace(), | ||||||
|  |                      'trace function introduces __locals__ unexpectedly') | ||||||
|     def test_virtualClassAttributeWithOneMeta(self): |     def test_virtualClassAttributeWithOneMeta(self): | ||||||
|         class Meta(type): |         class Meta(type): | ||||||
|             def __dir__(cls): |             def __dir__(cls): | ||||||
|  | @ -747,6 +756,10 @@ class Class(metaclass=Meta): | ||||||
|             print_diffs(expected_text, result) |             print_diffs(expected_text, result) | ||||||
|             self.fail("outputs are not equal, see diff above") |             self.fail("outputs are not equal, see diff above") | ||||||
| 
 | 
 | ||||||
|  |     @unittest.skipIf(sys.flags.optimize >= 2, | ||||||
|  |                      "Docstrings are omitted with -O2 and above") | ||||||
|  |     @unittest.skipIf(hasattr(sys, 'gettrace') and sys.gettrace(), | ||||||
|  |                      'trace function introduces __locals__ unexpectedly') | ||||||
|     def test_virtualClassAttributeWithTwoMeta(self): |     def test_virtualClassAttributeWithTwoMeta(self): | ||||||
|         class Meta1(type): |         class Meta1(type): | ||||||
|             def __dir__(cls): |             def __dir__(cls): | ||||||
|  | @ -795,6 +808,10 @@ class Class2(Class1, metaclass=Meta3): | ||||||
|         if fail1 or fail2: |         if fail1 or fail2: | ||||||
|             self.fail("outputs are not equal, see diff above") |             self.fail("outputs are not equal, see diff above") | ||||||
| 
 | 
 | ||||||
|  |     @unittest.skipIf(sys.flags.optimize >= 2, | ||||||
|  |                      "Docstrings are omitted with -O2 and above") | ||||||
|  |     @unittest.skipIf(hasattr(sys, 'gettrace') and sys.gettrace(), | ||||||
|  |                      'trace function introduces __locals__ unexpectedly') | ||||||
|     def test_buggy_dir(self): |     def test_buggy_dir(self): | ||||||
|         class M(type): |         class M(type): | ||||||
|             def __dir__(cls): |             def __dir__(cls): | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Ethan Furman
						Ethan Furman