def monkeypatch_xunit(): try: knownfailureif(True)(lambda: None)() except Exception as e: KnownFailureTest = type(e) def addError(self, test, err, capt=None): if issubclass(err[0], KnownFailureTest): err = (SkipTest, ) + err[1:] return self.orig_addError(test, err, capt) Xunit.orig_addError = Xunit.addError Xunit.addError = addError
def monkeypatch_xunit(): try: knownfailureif(True)(lambda: None)() except Exception as e: KnownFailureTest = type(e) def addError(self, test, err, capt=None): if issubclass(err[0], KnownFailureTest): err = (SkipTest,) + err[1:] return self.orig_addError(test, err, capt) Xunit.orig_addError = Xunit.addError Xunit.addError = addError
return decorated_dummy(skip_if_no_x11, name) if _x11_skip_cond else None # Other skip decorators # generic skip without module skip_without = lambda mod: skipif(module_not_available(mod), "This test requires %s" % mod) skipif_not_numpy = skip_without('numpy') skipif_not_matplotlib = skip_without('matplotlib') skipif_not_sympy = skip_without('sympy') skip_known_failure = knownfailureif(True, 'This test is known to fail') # A null 'decorator', useful to make more readable code that needs to pick # between different decorators based on OS or other conditions null_deco = lambda f: f # Some tests only run where we can use unicode paths. Note that we can't just # check os.path.supports_unicode_filenames, which is always False on Linux. try: f = tempfile.NamedTemporaryFile(prefix=u"tmp€") except UnicodeEncodeError: unicode_paths = False else: unicode_paths = True f.close()