(request, tz_naive_fixture, _offset)
| 109 | |
| 110 | @pytest.mark.skipif(WASM, reason="OverflowError received on WASM") |
| 111 | def test_apply_out_of_range(request, tz_naive_fixture, _offset): |
| 112 | tz = tz_naive_fixture |
| 113 | |
| 114 | # try to create an out-of-bounds result timestamp; if we can't create |
| 115 | # the offset skip |
| 116 | try: |
| 117 | if _offset in (BusinessHour, CustomBusinessHour): |
| 118 | # Using 10000 in BusinessHour fails in tz check because of DST |
| 119 | # difference |
| 120 | offset = _get_offset(_offset, value=100000) |
| 121 | else: |
| 122 | offset = _get_offset(_offset, value=10000) |
| 123 | |
| 124 | result = Timestamp("20080101") + offset |
| 125 | assert isinstance(result, datetime) |
| 126 | assert result.tzinfo is None |
| 127 | |
| 128 | # Check tz is preserved |
| 129 | t = Timestamp("20080101", tz=tz) |
| 130 | result = t + offset |
| 131 | assert isinstance(result, datetime) |
| 132 | if tz is not None: |
| 133 | assert t.tzinfo is not None |
| 134 | |
| 135 | if ( |
| 136 | isinstance(tz, tzlocal) |
| 137 | and ((not IS64) or WASM) |
| 138 | and _offset is not DateOffset |
| 139 | ): |
| 140 | # If we hit OutOfBoundsDatetime on non-64 bit machines |
| 141 | # we'll drop out of the try clause before the next test |
| 142 | request.applymarker( |
| 143 | pytest.mark.xfail(reason="OverflowError inside tzlocal past 2038") |
| 144 | ) |
| 145 | elif ( |
| 146 | isinstance(tz, tzlocal) |
| 147 | and is_platform_windows() |
| 148 | and _offset in (QuarterEnd, BQuarterBegin, BQuarterEnd, FY5253Quarter) |
| 149 | ): |
| 150 | request.applymarker( |
| 151 | pytest.mark.xfail(reason="After GH#49737 t.tzinfo is None on CI") |
| 152 | ) |
| 153 | assert str(t.tzinfo) == str(result.tzinfo), (t.tzinfo, result.tzinfo) |
| 154 | |
| 155 | except OutOfBoundsDatetime: |
| 156 | pass |
| 157 | except (ValueError, KeyError, NotImplementedError, OverflowError, OSError): |
| 158 | # we are creating an invalid offset |
| 159 | # so ignore |
| 160 | # - NotImplementedError is raised for tz-aware timestamps outside Python's |
| 161 | # range that are created by adding the offset |
| 162 | # - OverflowError is raised in the same case on 32-bit systems with tzlocal |
| 163 | # - OSError is raised in the same case on Windows with tzlocal |
| 164 | pass |
| 165 | |
| 166 | |
| 167 | def test_offsets_compare_equal(_offset): |
nothing calls this directly
no test coverage detected