dateutil / dateutil
1 20
import os
2 20
import pytest
3

4

5
# Configure pytest to ignore xfailing tests
6
# See: https://stackoverflow.com/a/53198349/467366
7 20
def pytest_collection_modifyitems(items):
8 20
    for item in items:
9 20
        marker_getter = getattr(item, 'get_closest_marker', None)
10

11
        # Python 3.3 support
12 20
        if marker_getter is None:
13 0
            marker_getter = item.get_marker
14

15 20
        marker = marker_getter('xfail')
16

17
        # Need to query the args because conditional xfail tests still have
18
        # the xfail mark even if they are not expected to fail
19 20
        if marker and (not marker.args or marker.args[0]):
20 20
            item.add_marker(pytest.mark.no_cover)
21

22

23 20
def set_tzpath():
24
    """
25
    Sets the TZPATH variable if it's specified in an environment variable.
26
    """
27 20
    tzpath = os.environ.get('DATEUTIL_TZPATH', None)
28

29 20
    if tzpath is None:
30 20
        return
31

32 0
    path_components = tzpath.split(':')
33

34 0
    print("Setting TZPATH to {}".format(path_components))
35

36 0
    from dateutil import tz
37 0
    tz.TZPATHS.clear()
38 0
    tz.TZPATHS.extend(path_components)
39

40

41 20
set_tzpath()

Read our documentation on viewing source code .

Loading