Test the NUMBER option.
(self, pytester, config_mode)
| 970 | |
| 971 | @pytest.mark.parametrize("config_mode", ["ini", "comment"]) |
| 972 | def test_number_precision(self, pytester, config_mode): |
| 973 | """Test the NUMBER option.""" |
| 974 | if config_mode == "ini": |
| 975 | pytester.makeini( |
| 976 | """ |
| 977 | [pytest] |
| 978 | doctest_optionflags = NUMBER |
| 979 | """ |
| 980 | ) |
| 981 | comment = "" |
| 982 | else: |
| 983 | comment = "#doctest: +NUMBER" |
| 984 | |
| 985 | pytester.maketxtfile( |
| 986 | test_doc=""" |
| 987 | |
| 988 | Scalars: |
| 989 | |
| 990 | >>> import math |
| 991 | >>> math.pi {comment} |
| 992 | 3.141592653589793 |
| 993 | >>> math.pi {comment} |
| 994 | 3.1416 |
| 995 | >>> math.pi {comment} |
| 996 | 3.14 |
| 997 | >>> -math.pi {comment} |
| 998 | -3.14 |
| 999 | >>> math.pi {comment} |
| 1000 | 3. |
| 1001 | >>> 3. {comment} |
| 1002 | 3.0 |
| 1003 | >>> 3. {comment} |
| 1004 | 3. |
| 1005 | >>> 3. {comment} |
| 1006 | 3.01 |
| 1007 | >>> 3. {comment} |
| 1008 | 2.99 |
| 1009 | >>> .299 {comment} |
| 1010 | .3 |
| 1011 | >>> .301 {comment} |
| 1012 | .3 |
| 1013 | >>> 951. {comment} |
| 1014 | 1e3 |
| 1015 | >>> 1049. {comment} |
| 1016 | 1e3 |
| 1017 | >>> -1049. {comment} |
| 1018 | -1e3 |
| 1019 | >>> 1e3 {comment} |
| 1020 | 1e3 |
| 1021 | >>> 1e3 {comment} |
| 1022 | 1000. |
| 1023 | |
| 1024 | Lists: |
| 1025 | |
| 1026 | >>> [3.1415, 0.097, 13.1, 7, 8.22222e5, 0.598e-2] {comment} |
| 1027 | [3.14, 0.1, 13., 7, 8.22e5, 6.0e-3] |
| 1028 | >>> [[0.333, 0.667], [0.999, 1.333]] {comment} |
| 1029 | [[0.33, 0.667], [0.999, 1.333]] |
nothing calls this directly
no test coverage detected