1 68
import os
2 68
import pytest
3

4

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

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

15 68
        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 68
        if marker and (not marker.args or marker.args[0]):
20 68
            item.add_marker(pytest.mark.no_cover)
21

22

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

29 68
    if tzpath is None:
30 68
        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 68
set_tzpath()

Read our documentation on viewing source code .

Loading