()
| 56 | |
| 57 | |
| 58 | def test_eval_dates(): |
| 59 | MIN_YEAR = 1 # https://docs.python.org/3/library/datetime.html#datetime.MINYEAR |
| 60 | MAX_YEAR = 2023 |
| 61 | start = datetime(MIN_YEAR, 1, 1, 00, 00, 00, tzinfo=timezone.utc) |
| 62 | years = MAX_YEAR - MIN_YEAR + 1 |
| 63 | end = start + timedelta(days=365 * years) |
| 64 | for _ in range(10): |
| 65 | py_date = start + (end - start) * random.random() |
| 66 | # round to milliseconds precision because the smallest unit for js Date is 1ms |
| 67 | # microsecond must be in 0..999999, but it would be rounded to 1000000 if >= 999500 |
| 68 | py_date = py_date.replace(microsecond=min(round(py_date.microsecond, -3), 999000)) |
| 69 | js_date = pm.eval(f'new Date("{py_date.isoformat()}")') |
| 70 | assert py_date == js_date |
| 71 | |
| 72 | |
| 73 | def test_eval_boxed_booleans(): |
nothing calls this directly
no outgoing calls
no test coverage detected