Make test_datetime a better citizen (issue #22540)