def check_module_skip(filename): with preserve_sys_path(), suppress_stdout(): module_dir = os.path.dirname(filename) if module_dir not in sys.path: sys.path.insert(0, module_dir) try: module = importlib.import_module(os.path.basename(os.path.splitext(filename)[0])) for name, obj in inspect.getmembers(module): if inspect.isfunction(obj) and name == "skip_test": return obj() except ImportError as exception: return str(exception) return False
def check_module_skip(filename): with preserve_sys_path(), suppress_stdout(): module_dir = os.path.dirname(filename) if module_dir not in sys.path: sys.path.insert(0, module_dir) try: module = importlib.import_module( os.path.basename(os.path.splitext(filename)[0])) for name, obj in inspect.getmembers(module): if inspect.isfunction(obj) and name == "skip_test": return obj() except ImportError as exception: return str(exception) return False
def test_preserve_sys_path(self): old_sys_path = copy.copy(sys.path) with preserve_sys_path(): sys.path = 5 self.assertEqual(old_sys_path, sys.path)