|
| 1 | +Traceback with variables (most recent call last): |
| 2 | + File "...omitted for tests only.../test_core.py", line 13, in check_ |
| 3 | + > f() |
| 4 | + . except Exception: # noqa |
| 5 | + . tb_reg(core.format_exc(**kwargs)) |
| 6 | + . |
| 7 | + . return check_ |
| 8 | + . |
| 9 | + . |
| 10 | + . def test_replace(): |
| 11 | + . fmt = Format( |
| 12 | + . max_value_str_len=1, |
| 13 | + . objects_details=1, |
| 14 | + . ellipsis_rel_pos=0.5, |
| 15 | + . max_exc_str_len=1, |
| 16 | + . ellipsis_='.', |
| 17 | + . before=1, |
| 18 | + . after=1, |
| 19 | + . color_scheme=None, |
| 20 | + . skip_files_except=[], |
| 21 | + . brief_files_except=[], |
| 22 | + . custom_var_printers=[], |
| 23 | + . ) |
| 24 | + . fmt2 = fmt.replace( |
| 25 | + . before=2, |
| 26 | + . skip_files_except=['f1', 'f2'], |
| 27 | + . ) |
| 28 | + . assert fmt.max_value_str_len == fmt.max_value_str_len |
| 29 | + . assert fmt2.before == 2 |
| 30 | + . assert fmt.before == 1 |
| 31 | + . assert fmt2.skip_files_except == ['f1', 'f2'] |
| 32 | + . assert fmt.skip_files_except == [] |
| 33 | + . |
| 34 | + . |
| 35 | + . def test_setattr(): |
| 36 | + . fmt = Format() |
| 37 | + . fmt.max_value_str_len = 1 |
| 38 | + . fmt.objects_details = 1 |
| 39 | + . fmt.ellipsis_rel_pos = 0.5 |
| 40 | + . fmt.max_exc_str_len = 1 |
| 41 | + . fmt.ellipsis_ = '.' |
| 42 | + . fmt.before = 1 |
| 43 | + . fmt.after = 1 |
| 44 | + . fmt.color_scheme = None |
| 45 | + . fmt.skip_files_except = [] |
| 46 | + . fmt.brief_files_except = [] |
| 47 | + . fmt.custom_var_printers = [] |
| 48 | + . with pytest.raises(AttributeError) as e: |
| 49 | + . fmt.max_val_str_len = 1 |
| 50 | + . assert str(e.value) == "'Format' object has no attribute 'max_val_str_len'" |
| 51 | + . |
| 52 | + . |
| 53 | + . def test_default(check): |
| 54 | + . check() |
| 55 | + . |
| 56 | + . |
| 57 | + . def test_explicit_e(tb_reg): |
| 58 | + . try: |
| 59 | + . f() |
| 60 | + . except Exception as e_: # noqa |
| 61 | + . e = e_ |
| 62 | + . |
| 63 | + . tb_reg(core.format_exc(e=e)) # noqa |
| 64 | + . |
| 65 | + . |
| 66 | + . def test_no_e(): |
| 67 | + . try: |
| 68 | + . f() |
| 69 | + . except: # noqa |
| 70 | + . pass |
| 71 | + . |
| 72 | + . with pytest.raises(ValueError): |
| 73 | + . core.format_exc() |
| 74 | + . |
| 75 | + . |
| 76 | + . # TODO def test_after_unhandled_e(): |
| 77 | + . |
| 78 | + . |
| 79 | + . def test_ellipsis(check): |
| 80 | + . check(fmt=Format(ellipsis_='*')) |
| 81 | + . |
| 82 | + . |
| 83 | + . def test_max_value_str_len(check): |
| 84 | + . check(fmt=Format(max_value_str_len=100)) |
| 85 | + . |
| 86 | + . |
| 87 | + . @pytest.mark.parametrize('obj', [[1, 2, 3], A(11, 12), A(A(11, 12), A(13, 14)), A(Unprintable(), 2)]) |
| 88 | + . @pytest.mark.parametrize('objects_details', [0, 1, 10]) |
| 89 | + . def test_objects_details(tb_reg, obj, objects_details): |
| 90 | + . try: |
| 91 | + . 1/0 |
| 92 | + kwargs = {'fmt': traceback_with_variables.core.Format(after=100, before=0, brief_files_except=[], color_scheme=None, custom_var_printers=[], ellipsis_='...', ellipsis_rel_pos=0.7, max_exc_str_len=10000, max_value_str_len=1000, objects_details=1, skip_files_except=[])} |
| 93 | + tb_reg = <bound method Reg.match_tb_text of <tests.test_utils.Reg object at 0x...omitted for tests only...>> |
| 94 | + File "...omitted for tests only.../dummies.py", line 92, in f |
| 95 | + > return f( |
| 96 | + . n |
| 97 | + . |
| 98 | + . - 1 |
| 99 | + . ) |
| 100 | + n = 10001 |
| 101 | + s1 = 'short string with n: 10001' |
| 102 | + l1 = 'long string with 0..n: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156...9951, 9952, 9953, 9954, 9955, 9956, 9957, 9958, 9959, 9960, 9961, 9962, 9963, 9964, 9965, 9966, 9967, 9968, 9969, 9970, 9971, 9972, 9973, 9974, 9975, 9976, 9977, 9978, 9979, 9980, 9981, 9982, 9983, 9984, 9985, 9986, 9987, 9988, 9989, 9990, 9991, 9992, 9993, 9994, 9995, 9996, 9997, 9998, 9999, 10000' |
| 103 | + us = <exception while printing> Traceback (most recent call last): |
| 104 | + ...traceback_with_variables internal stacks... |
| 105 | + File "...omitted for tests only.../dummies.py", line 29, in __repr__ |
| 106 | + raise ValueError("please don't print me") |
| 107 | + ValueError: please don't print me |
| 108 | + |
| 109 | + File "...omitted for tests only.../dummies.py", line 86, in f |
| 110 | + > return 1 // (n * 0) |
| 111 | + . |
| 112 | + . if True: |
| 113 | + . if n % 2 == 0: |
| 114 | + . return f(n - 1) |
| 115 | + . else: |
| 116 | + . return f( |
| 117 | + . n |
| 118 | + . |
| 119 | + . - 1 |
| 120 | + . ) |
| 121 | + n = 10000 |
| 122 | + s1 = 'short string with n: 10000' |
| 123 | + l1 = 'long string with 0..n: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156... 9950, 9951, 9952, 9953, 9954, 9955, 9956, 9957, 9958, 9959, 9960, 9961, 9962, 9963, 9964, 9965, 9966, 9967, 9968, 9969, 9970, 9971, 9972, 9973, 9974, 9975, 9976, 9977, 9978, 9979, 9980, 9981, 9982, 9983, 9984, 9985, 9986, 9987, 9988, 9989, 9990, 9991, 9992, 9993, 9994, 9995, 9996, 9997, 9998, 9999' |
| 124 | + us = <exception while printing> Traceback (most recent call last): |
| 125 | + ...traceback_with_variables internal stacks... |
| 126 | + File "...omitted for tests only.../dummies.py", line 29, in __repr__ |
| 127 | + raise ValueError("please don't print me") |
| 128 | + ValueError: please don't print me |
| 129 | + |
| 130 | +builtins.ZeroDivisionError: integer division or modulo by zero |
0 commit comments