| 
									
										
										
										
											2022-02-20 02:57:02 +00:00
										 |  |  | """Test the autodoc extension.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | This tests mainly the Documenters; the auto directives are tested in a test | 
					
						
							|  |  |  | source file translated by test_build. | 
					
						
							| 
									
										
										
										
											2021-03-11 02:01:17 +09:00
										 |  |  | """
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-22 23:25:02 +09:00
										 |  |  | import sys | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-11 02:01:17 +09:00
										 |  |  | import pytest | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | from .test_ext_autodoc import do_autodoc | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @pytest.mark.sphinx('html', testroot='ext-autodoc') | 
					
						
							|  |  |  | def test_properties(app): | 
					
						
							| 
									
										
										
										
											2021-07-17 15:02:23 +09:00
										 |  |  |     actual = do_autodoc(app, 'property', 'target.properties.Foo.prop1') | 
					
						
							| 
									
										
										
										
											2021-03-11 02:01:17 +09:00
										 |  |  |     assert list(actual) == [ | 
					
						
							|  |  |  |         '', | 
					
						
							| 
									
										
										
										
											2021-07-17 15:02:23 +09:00
										 |  |  |         '.. py:property:: Foo.prop1', | 
					
						
							| 
									
										
										
										
											2021-03-11 02:01:17 +09:00
										 |  |  |         '   :module: target.properties', | 
					
						
							|  |  |  |         '   :type: int', | 
					
						
							|  |  |  |         '', | 
					
						
							|  |  |  |         '   docstring', | 
					
						
							|  |  |  |         '', | 
					
						
							|  |  |  |     ] | 
					
						
							| 
									
										
										
										
											2021-07-17 15:02:23 +09:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @pytest.mark.sphinx('html', testroot='ext-autodoc') | 
					
						
							|  |  |  | def test_class_properties(app): | 
					
						
							|  |  |  |     actual = do_autodoc(app, 'property', 'target.properties.Foo.prop2') | 
					
						
							|  |  |  |     assert list(actual) == [ | 
					
						
							|  |  |  |         '', | 
					
						
							|  |  |  |         '.. py:property:: Foo.prop2', | 
					
						
							|  |  |  |         '   :module: target.properties', | 
					
						
							|  |  |  |         '   :classmethod:', | 
					
						
							|  |  |  |         '   :type: int', | 
					
						
							|  |  |  |         '', | 
					
						
							|  |  |  |         '   docstring', | 
					
						
							|  |  |  |         '', | 
					
						
							|  |  |  |     ] | 
					
						
							| 
									
										
										
										
											2021-07-22 23:25:02 +09:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @pytest.mark.skipif(sys.version_info < (3, 8), reason='python 3.8+ is required.') | 
					
						
							|  |  |  | @pytest.mark.sphinx('html', testroot='ext-autodoc') | 
					
						
							|  |  |  | def test_cached_properties(app): | 
					
						
							|  |  |  |     actual = do_autodoc(app, 'property', 'target.cached_property.Foo.prop') | 
					
						
							|  |  |  |     assert list(actual) == [ | 
					
						
							|  |  |  |         '', | 
					
						
							|  |  |  |         '.. py:property:: Foo.prop', | 
					
						
							|  |  |  |         '   :module: target.cached_property', | 
					
						
							|  |  |  |         '   :type: int', | 
					
						
							|  |  |  |         '', | 
					
						
							|  |  |  |     ] |