|  | 
| 21 | 21 | from test.test_zoneinfo import _support as test_support | 
| 22 | 22 | from test.test_zoneinfo._support import OS_ENV_LOCK, TZPATH_TEST_LOCK, ZoneInfoTestBase | 
| 23 | 23 | from test.support.import_helper import import_module, CleanImport | 
|  | 24 | +from test.support.script_helper import assert_python_ok | 
| 24 | 25 | 
 | 
| 25 | 26 | lzma = import_module('lzma') | 
| 26 | 27 | py_zoneinfo, c_zoneinfo = test_support.get_modules() | 
| @@ -1960,6 +1961,26 @@ class CTestModule(TestModule): | 
| 1960 | 1961 |     module = c_zoneinfo | 
| 1961 | 1962 | 
 | 
| 1962 | 1963 | 
 | 
|  | 1964 | +class MiscTests(unittest.TestCase): | 
|  | 1965 | +    def test_pydatetime(self): | 
|  | 1966 | +        # Test that zoneinfo works if the C implementation of datetime | 
|  | 1967 | +        # is not available and the Python implementation of datetime is used. | 
|  | 1968 | +        # The Python implementation of zoneinfo should be used in thet case. | 
|  | 1969 | +        # | 
|  | 1970 | +        # Run the test in a subprocess, as importing _zoneinfo with | 
|  | 1971 | +        # _datettime disabled causes crash in the previously imported | 
|  | 1972 | +        # _zoneinfo. | 
|  | 1973 | +        assert_python_ok('-c', '''if 1: | 
|  | 1974 | +            import sys | 
|  | 1975 | +            sys.modules['_datetime'] = None | 
|  | 1976 | +            import datetime | 
|  | 1977 | +            import zoneinfo | 
|  | 1978 | +            tzinfo = zoneinfo.ZoneInfo('Europe/London') | 
|  | 1979 | +            datetime.datetime(2025, 10, 26, 2, 0, tzinfo=tzinfo) | 
|  | 1980 | +            ''', | 
|  | 1981 | +            PYTHONTZPATH=str(ZONEINFO_DATA.tzpath)) | 
|  | 1982 | + | 
|  | 1983 | + | 
| 1963 | 1984 | class ExtensionBuiltTest(unittest.TestCase): | 
| 1964 | 1985 |     """Smoke test to ensure that the C and Python extensions are both tested. | 
| 1965 | 1986 | 
 | 
|  | 
0 commit comments