From: Vladimír Vondruš Date: Thu, 7 May 2020 20:07:19 +0000 (+0200) Subject: documentation/python: dedicated test for value formatting. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=commitdiff_plain;h=836d5fb588c8fdc6e879aae78cec0d2980c2e079;p=blog.git documentation/python: dedicated test for value formatting. --- diff --git a/documentation/test_python/inspect_string/inspect_string.html b/documentation/test_python/inspect_string/inspect_string.html index bfc5bb38..fb0bcb1a 100644 --- a/documentation/test_python/inspect_string/inspect_string.html +++ b/documentation/test_python/inspect_string/inspect_string.html @@ -104,26 +104,6 @@ A_CONSTANT = 3.24
-
- A_FALSE_VALUE = False -
-
-
- A_NONE_VALUE = None -
-
-
- A_ZERO_VALUE = 0 -
-
-
- ENUM_THING = MyEnum.YAY -
-
-
- LARGE_VALUE_WILL_BE_AN_ELLIPSIS = … -
-
foo
diff --git a/documentation/test_python/inspect_string/inspect_string/__init__.py b/documentation/test_python/inspect_string/inspect_string/__init__.py index 68ce6ac9..89ae9321 100644 --- a/documentation/test_python/inspect_string/inspect_string/__init__.py +++ b/documentation/test_python/inspect_string/inspect_string/__init__.py @@ -131,22 +131,6 @@ def function(): A_CONSTANT = 3.24 -# TODO: not visible ATM, need to figure out interaction with __all__ -DATA_DECLARATION: int - -ENUM_THING = MyEnum.YAY - -# These should have their value shown in the docs as well, even though they are -# not true-ish -A_ZERO_VALUE = 0 -A_FALSE_VALUE = False -A_NONE_VALUE = None - -# This value is too long and should be completely omitted -LARGE_VALUE_WILL_BE_AN_ELLIPSIS = """Lorem ipsum dolor sit amet, consectetur - adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore - magna aliqua.""" - _PRIVATE_CONSTANT = -3 foo = Foo() diff --git a/documentation/test_python/inspect_value_formatting/inspect_value_formatting.html b/documentation/test_python/inspect_value_formatting/inspect_value_formatting.html new file mode 100644 index 00000000..f89eac7e --- /dev/null +++ b/documentation/test_python/inspect_value_formatting/inspect_value_formatting.html @@ -0,0 +1,93 @@ + + + + + inspect_value_formatting | My Python Project + + + + + +
+
+
+
+
+

+ inspect_value_formatting module +

+

Value and default argument formatting

+
+

Contents

+ +
+
+

Enums

+
+
+ class MyEnum(enum.Enum): YAY = 2 +
+
+
+
+
+

Functions

+
+
+ def basics(string_param = 'string', + tuple_param = (3, 5), + float_param = 1.2) +
+
+
+ def setup_callback(callback = <function basics at 0x7fc2ca424ee0>) +
+
Should produce a deterministic output.
+
+
+
+

Data

+
+
+ A_FALSE_VALUE = False +
+
+
+ A_NONE_VALUE = None +
+
+
+ A_ZERO_VALUE = 0 +
+
+
+ ENUM_THING = MyEnum.YAY +
+
+
+ LARGE_VALUE_WILL_BE_AN_ELLIPSIS = … +
+
+
+
+
+
+
+
+ + diff --git a/documentation/test_python/inspect_value_formatting/inspect_value_formatting.py b/documentation/test_python/inspect_value_formatting/inspect_value_formatting.py new file mode 100644 index 00000000..d2b807d8 --- /dev/null +++ b/documentation/test_python/inspect_value_formatting/inspect_value_formatting.py @@ -0,0 +1,29 @@ +"""Value and default argument formatting""" + +import enum + +def basics(string_param = "string", tuple_param = (3, 5), float_param = 1.2): + pass + +def setup_callback(callback = basics): + """Should produce a deterministic output.""" + pass + +# TODO: not visible ATM, need to figure out interaction with __all__ +DATA_DECLARATION: int + +class MyEnum(enum.Enum): + YAY = 2 + +ENUM_THING = MyEnum.YAY + +# These should have their value shown in the docs as well, even though they are +# not true-ish +A_ZERO_VALUE = 0 +A_FALSE_VALUE = False +A_NONE_VALUE = None + +# This value is too long and should be completely omitted +LARGE_VALUE_WILL_BE_AN_ELLIPSIS = """Lorem ipsum dolor sit amet, consectetur + adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore + magna aliqua.""" diff --git a/documentation/test_python/test_inspect.py b/documentation/test_python/test_inspect.py index 57599dba..7ecf4278 100644 --- a/documentation/test_python/test_inspect.py +++ b/documentation/test_python/test_inspect.py @@ -252,3 +252,8 @@ class Underscored(BaseInspectTestCase): self.assertEqual(*self.actual_expected_contents('inspect_underscored.html')) self.assertEqual(*self.actual_expected_contents('inspect_underscored.Class.html')) + +class ValueFormatting(BaseInspectTestCase): + def test(self): + self.run_python({}) + self.assertEqual(*self.actual_expected_contents('inspect_value_formatting.html'))