| 1 |
# Licensed under the LGPL: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html |
| 2 |
# For details: https://github.com/pylint-dev/astroid/blob/main/LICENSE |
| 3 |
# Copyright (c) https://github.com/pylint-dev/astroid/blob/main/CONTRIBUTORS.txt |
| 4 |
|
| 5 |
from __future__ import annotations |
| 6 |
|
| 7 |
import unittest |
| 8 |
|
| 9 |
from astroid import builder |
| 10 |
|
| 11 |
try: |
| 12 |
import dateutil # type: ignore[import] # pylint: disable=unused-import |
| 13 |
|
| 14 |
HAS_DATEUTIL = True |
| 15 |
except ImportError: |
| 16 |
HAS_DATEUTIL = False |
| 17 |
|
| 18 |
|
| 19 |
@unittest.skipUnless(HAS_DATEUTIL, "This test requires the dateutil library.") |
| 20 |
class DateutilBrainTest(unittest.TestCase): |
| 21 |
def test_parser(self): |
| 22 |
module = builder.parse(""" |
| 23 |
from dateutil.parser import parse |
| 24 |
d = parse('2000-01-01') |
| 25 |
""") |
| 26 |
d_type = next(module["d"].infer()) |
| 27 |
self.assertIn(d_type.qname(), {"_pydatetime.datetime", "datetime.datetime"}) |