/usr/lib/python3/dist-packages/proboscis/dependencies.py is in python3-proboscis 1.2.6.0-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | # Copyright (c) 2011 Rackspace
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""Dynamically selected dependencies for Proboscis.
If Nose is installed, Proboscis will use it. Otherwise Proboscis will use the
default unittest framework, in order to function in IronPython and Jython. It
also supports Python 2.5 in order to work with Jython.
"""
try:
from nose.plugins.skip import SkipTest as ExternalSkipTest
from nose.core import TestProgram
from nose.core import TextTestResult
from nose.core import TextTestRunner
use_nose = True
def skip_test(test_self, message):
raise SkipTest(message)
except ImportError:
import unittest
from unittest import TextTestRunner
use_nose = False
# In 2.7 unittest.TestCase has a skipTest method.
def skip_test(test_self, message):
try:
test_self.skipTest(message)
except AttributeError: # For versions prior to 2.5.
raise AssertionError("SKIPPED:%s" % message)
class TestProgram(unittest.TestProgram):
def __init__(self, suite, config=None, *args, **kwargs):
self.suite_arg = suite
class StubLoader(object):
def loadTestsFromModule(*args, **kwargs):
return self.suite_arg
self.test = suite
if 'testLoader' not in kwargs or kwargs['testLoader'] is None:
kwargs['testLoader'] = StubLoader()
super(TestProgram, self).__init__(*args, **kwargs)
def createTests(self):
self.test = self.suite_arg
class TextTestResult(unittest._TextTestResult):
def __init__(self, stream, descriptions, verbosity, config=None,
errorClasses=None):
super(TextTestResult, self).__init__(stream, descriptions,
verbosity);
class ExternalSkipTest(Exception):
def __init__(self, message):
super(ExternalSkipTest, self).__init__(self, message)
self.message = message
def __str__(self):
return self.message
# Doing it this way so I won't change Nose's pydoc.
class SkipTest(ExternalSkipTest):
"""
Raise this to skip a test.
If Nose is available its SkipTest is used.
Otherwise Proboscis creates its own which class that calls
unittest.TestCase.skipTest. If that method isn't available (anything under
2.7) then skipping does not work and test errors are presented.
"""
pass
|