summaryrefslogtreecommitdiffstats
path: root/clang/bindings/python/tests/cindex/util.py
diff options
context:
space:
mode:
Diffstat (limited to 'clang/bindings/python/tests/cindex/util.py')
-rw-r--r--clang/bindings/python/tests/cindex/util.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/clang/bindings/python/tests/cindex/util.py b/clang/bindings/python/tests/cindex/util.py
index c53ba7c81bd..57e17941c55 100644
--- a/clang/bindings/python/tests/cindex/util.py
+++ b/clang/bindings/python/tests/cindex/util.py
@@ -1,5 +1,15 @@
# This file provides common utility functions for the test suite.
+import os
+HAS_FSPATH = hasattr(os, 'fspath')
+
+if HAS_FSPATH:
+ from pathlib import Path as str_to_path
+else:
+ str_to_path = None
+
+import unittest
+
from clang.cindex import Cursor
from clang.cindex import TranslationUnit
@@ -68,8 +78,13 @@ def get_cursors(source, spelling):
return cursors
+skip_if_no_fspath = unittest.skipUnless(HAS_FSPATH,
+ "Requires file system path protocol / Python 3.6+")
+
__all__ = [
'get_cursor',
'get_cursors',
'get_tu',
+ 'skip_if_no_fspath',
+ 'str_to_path',
]
OpenPOWER on IntegriCloud