| 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 |
|
| 11 |
def 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 |
|
| 23 |
def 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 |
if fragment in self.logfile.filename: |
| 28 |
self.skipTest(msg) |
| 29 |
else: |
| 30 |
testfunc(self, *args, **kwargs) |
| 31 |
return testwrapper |
| 32 |
return testdecorator |