From: Vladimír Vondruš Date: Sun, 15 Sep 2019 15:53:25 +0000 (+0200) Subject: documentation/python: test that a slot is properly added to search. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=commitdiff_plain;h=17f89febfd7561530dc6039a57c247d3573c6841;p=blog.git documentation/python: test that a slot is properly added to search. It's not because extract_property_doc() has a few early returns that fail to execute the search-adding code. --- diff --git a/documentation/test_python/search/search/__init__.py b/documentation/test_python/search/search/__init__.py index 990a9bbd..1745bfb3 100644 --- a/documentation/test_python/search/search/__init__.py +++ b/documentation/test_python/search/search/__init__.py @@ -21,3 +21,8 @@ def a_function(): def func_with_params(a, b): pass + +class FooWithSlots: + __slots__ = ('im_a_sloth',) + + im_a_sloth: bool diff --git a/documentation/test_python/test_search.py b/documentation/test_python/test_search.py index a0a684af..e783b29f 100644 --- a/documentation/test_python/test_search.py +++ b/documentation/test_python/test_search.py @@ -42,71 +42,77 @@ class Search(BaseInspectTestCase): with open(os.path.join(self.path, 'output', searchdata_filename), 'rb') as f: serialized = f.read() search_data_pretty = pretty_print(serialized, entryTypeClass=EntryType)[0] - #print(search_data_pretty) - self.assertEqual(len(serialized), 2076) + print(search_data_pretty) + self.assertEqual(len(serialized), 2269) self.assertEqual(search_data_pretty, """ -19 symbols -search [12] +21 symbols +search [14] || .$ || foo [7] || || .$ || || enum [0] -|| || | .$ -|| || | a_value [1] -|| || | nother [2] -|| || a_method [3] -|| || | | ($ -|| || | | ) [4] -|| || | property [5] -|| || data_declaration [6] -|| |unc_with_params [10] +|| || || .$ +|| || || a_value [1] +|| || || nother [2] +|| || |a_method [3] +|| || || | ($ +|| || || | ) [4] +|| || || property [5] +|| || |data_declaration [6] +|| || withslots [9] +|| || | .$ +|| || | im_a_sloth [8] +|| |unc_with_params [12] || || ($ -|| || ) [11] -|| a_function [8] +|| || ) [13] +|| a_function [10] || | ($ -|| | ) [9] -|| pybind [24] +|| | ) [11] +|| pybind [26] || | .$ -|| | foo [19] +|| | foo [21] || | | .$ -|| | | overloaded_method [15, 17, 13] +|| | | overloaded_method [17, 19, 15] || | | ($ -|| | | ) [16, 18, 14] -|| | unction [20] +|| | | ) [18, 20, 16] +|| | unction [22] || | | ($ -|| | | ) [21] -|| | | _with_params [22] +|| | | ) [23] +|| | | _with_params [24] || | | | ($ -|| | | | ) [23] -|| sub [26] +|| | | | ) [25] +|| sub [28] || | .$ -|| | data_in_a_submodule [25] -|ub [26] +|| | data_in_a_submodule [27] +|ub [28] || .$ -|| data_in_a_submodule [25] -foo [7, 19] +|| data_in_a_submodule [27] +foo [7, 21] || .$ || enum [0] -|| | .$ -|| | a_value [1] -|| | nother [2] -|| a_method [3] -|| | | ($ -|| | | ) [4] -|| | property [5] -|| data_declaration [6] -|| overloaded_method [15, 17, 13] -|| | ($ -|| | ) [16, 18, 14] -|unc_with_params [10] +|| || .$ +|| || a_value [1] +|| || nother [2] +|| |a_method [3] +|| || | ($ +|| || | ) [4] +|| || property [5] +|| |data_declaration [6] +|| |overloaded_method [17, 19, 15] +|| || ($ +|| || ) [18, 20, 16] +|| withslots [9] +|| | .$ +|| | im_a_sloth [8] +|unc_with_params [12] || | ($ -|| | ) [11] -|| tion [20] +|| | ) [13] +|| tion [22] || | ($ -|| | ) [21] -|| | _with_params [22] +|| | ) [23] +|| | _with_params [24] || | | ($ -|| | | ) [23] +|| | | ) [25] enum [0] | .$ | a_value [1] @@ -116,28 +122,29 @@ a_value [1] ||| ($ ||| ) [4] ||property [5] -||function [8] +||function [10] ||| ($ -||| ) [9] +||| ) [11] |nother [2] data_declaration [6] -| in_a_submodule [25] -pybind [24] +| in_a_submodule [27] +im_a_sloth [8] +pybind [26] | .$ -| foo [19] +| foo [21] | | .$ -| | overloaded_method [15, 17, 13] +| | overloaded_method [17, 19, 15] | | ($ -| | ) [16, 18, 14] -| unction [20] +| | ) [18, 20, 16] +| unction [22] | | ($ -| | ) [21] -| | _with_params [22] +| | ) [23] +| | _with_params [24] | | | ($ -| | | ) [23] -overloaded_method [15, 17, 13] +| | | ) [25] +overloaded_method [17, 19, 15] | ($ -| ) [16, 18, 14] +| ) [18, 20, 16] 0: .Enum [prefix=7[:15], type=ENUM] -> #Enum 1: .A_VALUE [prefix=0[:20], type=ENUM_VALUE] -> -A_VALUE 2: .ANOTHER [prefix=0[:20], type=ENUM_VALUE] -> -ANOTHER @@ -145,26 +152,28 @@ overloaded_method [15, 17, 13] 4: [prefix=3[:24], type=FUNCTION] -> 5: .a_property [prefix=7[:15], type=PROPERTY] -> #a_property 6: .DATA_DECLARATION [prefix=7[:15], type=DATA] -> #DATA_DECLARATION -7: .Foo [prefix=12[:7], type=CLASS] -> Foo.html -8: .a_function() [prefix=12[:11], suffix_length=2, type=FUNCTION] -> #a_function -9: [prefix=8[:22], type=FUNCTION] -> -10: .func_with_params() [prefix=12[:11], suffix_length=2, type=FUNCTION] -> #func_with_params -11: [prefix=10[:28], type=FUNCTION] -> -12: search [type=MODULE] -> search.html -13: .overloaded_method(self, first: int, second: float) [prefix=19[:22], suffix_length=33, type=FUNCTION] -> #overloaded_method-27269 -14: [prefix=13[:46], suffix_length=31, type=FUNCTION] -> -15: .overloaded_method(self, arg0: int) [prefix=19[:22], suffix_length=17, type=FUNCTION] -> #overloaded_method-745a3 -16: [prefix=15[:46], suffix_length=15, type=FUNCTION] -> -17: .overloaded_method(self, arg0: int, arg1: Foo) [prefix=19[:22], suffix_length=28, type=FUNCTION] -> #overloaded_method-41cfb -18: [prefix=17[:46], suffix_length=26, type=FUNCTION] -> -19: .Foo [prefix=24[:14], type=CLASS] -> Foo.html -20: .function() [prefix=24[:18], suffix_length=2, type=FUNCTION] -> #function -21: [prefix=20[:27], type=FUNCTION] -> -22: .function_with_params() [prefix=24[:18], suffix_length=2, type=FUNCTION] -> #function_with_params -23: [prefix=22[:39], type=FUNCTION] -> -24: .pybind [prefix=12[:7], type=MODULE] -> pybind.html -25: .DATA_IN_A_SUBMODULE [prefix=26[:15], type=DATA] -> #DATA_IN_A_SUBMODULE -26: .sub [prefix=12[:7], type=MODULE] -> sub.html +7: .Foo [prefix=14[:7], type=CLASS] -> Foo.html +8: .im_a_sloth [prefix=9[:24], type=PROPERTY] -> #im_a_sloth +9: WithSlots [prefix=7[:10], type=CLASS] -> WithSlots.html +10: .a_function() [prefix=14[:11], suffix_length=2, type=FUNCTION] -> #a_function +11: [prefix=10[:22], type=FUNCTION] -> +12: .func_with_params() [prefix=14[:11], suffix_length=2, type=FUNCTION] -> #func_with_params +13: [prefix=12[:28], type=FUNCTION] -> +14: search [type=MODULE] -> search.html +15: .overloaded_method(self, first: int, second: float) [prefix=21[:22], suffix_length=33, type=FUNCTION] -> #overloaded_method-27269 +16: [prefix=15[:46], suffix_length=31, type=FUNCTION] -> +17: .overloaded_method(self, arg0: int) [prefix=21[:22], suffix_length=17, type=FUNCTION] -> #overloaded_method-745a3 +18: [prefix=17[:46], suffix_length=15, type=FUNCTION] -> +19: .overloaded_method(self, arg0: int, arg1: Foo) [prefix=21[:22], suffix_length=28, type=FUNCTION] -> #overloaded_method-41cfb +20: [prefix=19[:46], suffix_length=26, type=FUNCTION] -> +21: .Foo [prefix=26[:14], type=CLASS] -> Foo.html +22: .function() [prefix=26[:18], suffix_length=2, type=FUNCTION] -> #function +23: [prefix=22[:27], type=FUNCTION] -> +24: .function_with_params() [prefix=26[:18], suffix_length=2, type=FUNCTION] -> #function_with_params +25: [prefix=24[:39], type=FUNCTION] -> +26: .pybind [prefix=14[:7], type=MODULE] -> pybind.html +27: .DATA_IN_A_SUBMODULE [prefix=28[:15], type=DATA] -> #DATA_IN_A_SUBMODULE +28: .sub [prefix=14[:7], type=MODULE] -> sub.html (EntryType.PAGE, CssClass.SUCCESS, 'page'), (EntryType.MODULE, CssClass.PRIMARY, 'module'), (EntryType.CLASS, CssClass.PRIMARY, 'class'),