1# -*- coding: utf-8 -*- 2# 3# Copyright (c) 2017, the cclib development team 4# 5# This file is part of cclib (http://cclib.github.io) and is distributed under 6# the terms of the BSD 3-Clause License. 7 8"""Tools for skipping data tests in cclib.""" 9 10 11def skipForParser(parser, msg): 12 """Return a decorator that skips the test for specified parser.""" 13 def testdecorator(testfunc): 14 def testwrapper(self, *args, **kwargs): 15 if self.logfile.logname == parser: 16 self.skipTest(msg) 17 else: 18 testfunc(self, *args, **kwargs) 19 return testwrapper 20 return testdecorator 21 22 23def skipForLogfile(fragment, msg): 24 """Return a decorator that skips the test for logfiles containing fragment.""" 25 def testdecorator(testfunc): 26 def testwrapper(self, *args, **kwargs): 27 # self.logfile.filename may be a string or list of strings. 28 if fragment in self.logfile.filename or any(fragment in filename for filename in self.logfile.filename): 29 self.skipTest(msg) 30 else: 31 testfunc(self, *args, **kwargs) 32 return testwrapper 33 return testdecorator 34