conftest.py 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import os
  2. import pytest
  3. # Configure pytest to ignore xfailing tests
  4. # See: https://stackoverflow.com/a/53198349/467366
  5. def pytest_collection_modifyitems(items):
  6. for item in items:
  7. marker_getter = getattr(item, 'get_closest_marker', None)
  8. # Python 3.3 support
  9. if marker_getter is None:
  10. marker_getter = item.get_marker
  11. marker = marker_getter('xfail')
  12. # Need to query the args because conditional xfail tests still have
  13. # the xfail mark even if they are not expected to fail
  14. if marker and (not marker.args or marker.args[0]):
  15. item.add_marker(pytest.mark.no_cover)
  16. def set_tzpath():
  17. """
  18. Sets the TZPATH variable if it's specified in an environment variable.
  19. """
  20. tzpath = os.environ.get('DATEUTIL_TZPATH', None)
  21. if tzpath is None:
  22. return
  23. path_components = tzpath.split(':')
  24. print("Setting TZPATH to {}".format(path_components))
  25. from dateutil import tz
  26. tz.TZPATHS.clear()
  27. tz.TZPATHS.extend(path_components)
  28. set_tzpath()