def setUp(self):
     if not os.path.isdir(TestSearchCommandsApp.app_root):
         build_command = os.path.join(project_root, 'examples',
                                      'searchcommands_app',
                                      'setup.py build')
         self.skipTest("You must build the searchcommands_app by running " +
                       build_command)
     TestCase.setUp(self)
    def __init__(self, fieldnames, data_generators):

        TestCase.__init__(self)

        self._data_generators = list(chain((lambda: self._serial_number, time), data_generators))
        self._fieldnames = list(chain(("_serial", "_time"), fieldnames))
        self._recorder = TestRecorder(self)
        self._serial_number = None
Ejemplo n.º 3
0
    def setUp(self):
        TestCase.setUp(self)

        self.converter = HTML2LatexConverter(
            context=object(),
            request=object(),
            layout=object())

        self.convert = self.converter.convert
Ejemplo n.º 4
0
    def __init__(self, fieldnames, data_generators):

        TestCase.__init__(self)

        self._data_generators = list(
            chain((lambda: self._serial_number, time), data_generators))
        self._fieldnames = list(chain(('_serial', '_time'), fieldnames))
        self._recorder = TestRecorder(self)
        self._serial_number = None
Ejemplo n.º 5
0
 def __init__(self, *args, **kwargs):
     # This is just to ensure the pytest runs with BF
     # this is done so that base prefixed/suffixed test method don't run
     UTest.__init__(self, "test_main")
     print(
         "Args passed while running with pytest: {}".format(
             [self.config, self.dev, self.env_helper]
         )
     )
Ejemplo n.º 6
0
 def run(self, result=None):
     # moved bits from original implementation of TestCase.run to
     # keep the way it works
     if result is None:
         result = self.defaultTestResult()
         startTestRun = getattr(result, 'startTestRun', None)
         if startTestRun is not None:
             startTestRun()
     TestCase.run(self, result)
     if not result.wasSuccessful() and failfast:
         result.shouldStop = True
Ejemplo n.º 7
0
    def __init__(self, *args, **kwargs):
        TestCase.__init__(self, *args, **kwargs)
        alibabacloud.utils._test_flag = True
        if sys.version_info[0] == 2:
            self.assertRegex = self.assertRegexpMatches

        self._sdk_config = self._init_sdk_config()
        self.access_key_id = self._read_key_from_env_or_config("ACCESS_KEY_ID")
        self.access_key_secret = self._read_key_from_env_or_config(
            "ACCESS_KEY_SECRET")
        self.region_id = self._read_key_from_env_or_config("REGION_ID")
        self.ecs = self._get_ecs_resource()
Ejemplo n.º 8
0
def state_wait(lfunction, final_set=set(), valid_set=None):
    #TODO(afazekas): evaluate using ABC here
    if not isinstance(final_set, set):
        final_set = set((final_set, ))
    if not isinstance(valid_set, set) and valid_set is not None:
        valid_set = set((valid_set, ))
    start_time = time.time()
    old_status = status = lfunction()
    while True:
        if status != old_status:
            LOG.info('State transition "%s" ==> "%s" %d second', old_status,
                     status,
                     time.time() - start_time)
        if status in final_set:
            return status
        if valid_set is not None and status not in valid_set:
            return status
        dtime = time.time() - start_time
        if dtime > default_timeout:
            raise TestCase.failureException("State change timeout exceeded!"
                                            '(%ds) While waiting'
                                            'for %s at "%s"' %
                                            (dtime, final_set, status))
        time.sleep(default_check_interval)
        old_status = status
        status = lfunction()
Ejemplo n.º 9
0
def state_wait(lfunction, final_set=set(), valid_set=None):
    #TODO(afazekas): evaluate using ABC here
    if not isinstance(final_set, set):
        final_set = set((final_set,))
    if not isinstance(valid_set, set) and valid_set is not None:
        valid_set = set((valid_set,))
    start_time = time.time()
    old_status = status = lfunction()
    while True:
        if status != old_status:
            LOG.info('State transition "%s" ==> "%s" %d second', old_status,
                     status, time.time() - start_time)
        if status in final_set:
            return status
        if valid_set is not None and status not in valid_set:
            return status
        dtime = time.time() - start_time
        if dtime > default_timeout:
            raise TestCase.failureException("State change timeout exceeded!"
                                            '(%ds) While waiting'
                                            'for %s at "%s"' %
                                            (dtime,
                                            final_set, status))
        time.sleep(default_check_interval)
        old_status = status
        status = lfunction()
Ejemplo n.º 10
0
def wait_no_exception(lfunction, exc_class=None, exc_matcher=None):
    """Stops waiting on success"""
    start_time = time.time()
    if exc_matcher is not None:
        exc_class = BotoServerError

    if exc_class is None:
        exc_class = BaseException
    while True:
        result = None
        try:
            result = lfunction()
            LOG.info('No Exception in %d second',
                     time.time() - start_time)
            return result
        except exc_class as exc:
            if exc_matcher is not None:
                res = exc_matcher.match(exc)
                if res is not None:
                    LOG.info(res)
                    raise exc
        # Let the other exceptions propagate
        dtime = time.time() - start_time
        if dtime > default_timeout:
            raise TestCase.failureException("Wait timeout exceeded! (%ds)" %
                                            dtime)
        time.sleep(default_check_interval)
Ejemplo n.º 11
0
def wait_no_exception(lfunction, exc_class=None, exc_matcher=None):
    """Stops waiting on success"""
    start_time = time.time()
    if exc_matcher is not None:
        exc_class = BotoServerError

    if exc_class is None:
        exc_class = BaseException
    while True:
        result = None
        try:
            result = lfunction()
            LOG.info('No Exception in %d second', time.time() - start_time)
            return result
        except exc_class as exc:
            if exc_matcher is not None:
                res = exc_matcher.match(exc)
                if res is not None:
                    LOG.info(res)
                    raise exc
        # Let the other exceptions propagate
        dtime = time.time() - start_time
        if dtime > default_timeout:
            raise TestCase.failureException("Wait timeout exceeded! (%ds)" %
                                            dtime)
        time.sleep(default_check_interval)
Ejemplo n.º 12
0
 def assert_(self, *args, **kwargs):
     if sys.version_info >= (2, 7):
         # The unittest2 library uses this deprecated method, we can't raise
         # the exception.
         raise DeprecationWarning(
             'The {0}() function is deprecated. Please start using {1}() '
             'instead.'.format('assert_', 'assertTrue')
         )
     return _TestCase.assert_(self, *args, **kwargs)
Ejemplo n.º 13
0
    def __init__(self, methodName='runTest'):
        TestCase.__init__(self, methodName=methodName)
        self.maxDiff = None
        self.eq = self.assertEqual
        self.neq = self.assertNotEqual

        self.true = self.assertTrue
        self.false = self.assertFalse

        self.isin = self.assertIn
        self.not_in = self.assertNotIn
        self.almost_eq = self.assertAlmostEqual

        self.isinstance = self.assertIsInstance
        self.not_isinstance = self.assertNotIsInstance

        self.raises = self.assertRaises
        self.items_eq = self.assertItemsEqual
Ejemplo n.º 14
0
    def __init__(self, methodName='runTest'):
        TestCase.__init__(self, methodName=methodName)
        self.maxDiff = None
        self.eq = self.assertEqual
        self.neq = self.assertNotEqual

        self.true = self.assertTrue
        self.false = self.assertFalse

        self.isin = self.assertIn
        self.not_in = self.assertNotIn
        self.almost_eq = self.assertAlmostEqual

        self.isinstance = self.assertIsInstance
        self.not_isinstance = self.assertNotIsInstance

        self.raises = self.assertRaises
        self.items_eq = self.assertItemsEqual
        self.raises_re = self.assertRaisesRegexp
Ejemplo n.º 15
0
    def test_check_permissions_fails_with_nobody(self):
        mtool = self.mocker.mock()
        self.expect(mtool.getAuthenticatedMember()).result(
            SpecialUsers.nobody)
        self.mock_tool(mtool, 'portal_membership')

        self.replay()

        view = ResolveOGUIDView(object(), object())

        with TestCase.assertRaises(self, Unauthorized):
            view._check_permissions(object())
Ejemplo n.º 16
0
def wait_exception(lfunction):
    """Returns with the exception or raises one"""
    start_time = time.time()
    while True:
        try:
            lfunction()
        except BaseException as exc:
            LOG.info('Exception in %d second', time.time() - start_time)
            return exc
        dtime = time.time() - start_time
        if dtime > default_timeout:
            raise TestCase.failureException("Wait timeout exceeded! (%ds)" %
                                            dtime)
        time.sleep(default_check_interval)
Ejemplo n.º 17
0
    def test_check_permission_fails_without_view_permission(self):
        obj = self.mocker.mock()

        mtool = self.mocker.mock()
        self.expect(mtool.getAuthenticatedMember().checkPermission(
                'View', obj)).result(False)
        self.mock_tool(mtool, 'portal_membership')

        self.replay()

        view = ResolveOGUIDView(object(), object())

        with TestCase.assertRaises(self, Unauthorized):
            view._check_permissions(obj)
Ejemplo n.º 18
0
def wait_exception(lfunction):
    """Returns with the exception or raises one"""
    start_time = time.time()
    while True:
        try:
            lfunction()
        except BaseException as exc:
            LOG.info('Exception in %d second',
                     time.time() - start_time)
            return exc
        dtime = time.time() - start_time
        if dtime > default_timeout:
            raise TestCase.failureException("Wait timeout exceeded! (%ds)" %
                                            dtime)
        time.sleep(default_check_interval)
Ejemplo n.º 19
0
    def test_validator(self):
        request = self.mocker.mock()
        self.expect(request.get('PATH_INFO', ANY)).result('somepath/++add++type')

        field = lifecycle.ILifeCycle['custody_period']

        context = None
        view = None
        widget = None

        self.replay()

        validator = getMultiAdapter((context, request, view, field, widget), IValidator)
        validator.validate(20)

        with TestCase.assertRaises(self, ConstraintNotSatisfied):
            validator.validate(15)
Ejemplo n.º 20
0
def re_search_wait(lfunction, regexp):
    """Stops waiting on success"""
    start_time = time.time()
    while True:
        text = lfunction()
        result = re.search(regexp, text)
        if result is not None:
            LOG.info('Pattern "%s" found in %d second in "%s"', regexp,
                     time.time() - start_time, text)
            return result
        dtime = time.time() - start_time
        if dtime > default_timeout:
            raise TestCase.failureException('Pattern find timeout exceeded!'
                                            '(%ds) While waiting for'
                                            '"%s" pattern in "%s"' %
                                            (dtime, regexp, text))
        time.sleep(default_check_interval)
Ejemplo n.º 21
0
def re_search_wait(lfunction, regexp):
    """Stops waiting on success"""
    start_time = time.time()
    while True:
        text = lfunction()
        result = re.search(regexp, text)
        if result is not None:
            LOG.info('Pattern "%s" found in %d second in "%s"',
                     regexp,
                     time.time() - start_time,
                     text)
            return result
        dtime = time.time() - start_time
        if dtime > default_timeout:
            raise TestCase.failureException('Pattern find timeout exceeded!'
                                            '(%ds) While waiting for'
                                            '"%s" pattern in "%s"' %
                                            (dtime,
                                            regexp, text))
        time.sleep(default_check_interval)
Ejemplo n.º 22
0
    def test_validator_in_context(self):
        request = self.mocker.mock()
        self.expect(request.get('PATH_INFO', ANY)).result(
            'somepath/++add++type').count(0, None)

        context = self.mocker.mock()
        self.expect(context.REQUEST).result(request).count(0, None)
        self.expect(context.custody_period).result(20).count(0, None)
        self.expect(context.aq_inner).result(context).count(0, None)
        self.expect(context.aq_parent).result(None).count(0, None)

        field = lifecycle.ILifeCycle['custody_period']

        view = None
        widget = None

        self.replay()

        validator = getMultiAdapter((context, request, view, field, widget), IValidator)
        validator.validate(20)
        validator.validate(30)

        with TestCase.assertRaises(self, ConstraintNotSatisfied):
            validator.validate(10)
Ejemplo n.º 23
0
 def tearDown(self):
     TestCase.tearDown(self)
     global dummyplugin
     dummyplugin = None
Ejemplo n.º 24
0
 def setUp(self):
     TestCase.setUp(self)
     self.tl = TodoList("todo.txt")
 def __init__(self, *args, **kwargs):
     TestCase.__init__(self, *args, **kwargs)
     
     if old_test_case:
         self.setUpClass()
 def setUp(self):
     TestCase.setUp(self)
     self.client = self.init_client()
Ejemplo n.º 27
0
 def __init__(self, method="runTest"):
     """Constructor."""
     TestCase.__init__(self, method)
     self.method = method
     self.pdb_script = None
     self.fnull = None
Ejemplo n.º 28
0
def verify_equal(expected, actual, msg=None):
    """Softly asserts that two values are equal."""
    try:
        TestCase(None).assertEqual(expected, actual, msg)
    except AssertionError, e:
        world.verification_errors.append(str(e))
Ejemplo n.º 29
0
 def __init__(self, *args, **kw):
     TestCase.__init__(self, *args, **kw)
     self.maxDiff = None
Ejemplo n.º 30
0
 def setUp(self):
     TestCase.setUp(self)
     self.client = Client("testuser", "testapikey")
    def __init__(self, *args, **kwargs):
        TestCase.__init__(self, *args, **kwargs)

        if old_test_case:
            self.setUpClass()
 def setUp(self):
     if not os.path.isdir(TestSearchCommandsApp.app_root):
         build_command = os.path.join(project_root, 'examples', 'searchcommands_app', 'setup.py build')
         self.skipTest("You must build the searchcommands_app by running " + build_command)
     TestCase.setUp(self)
Ejemplo n.º 33
0
import re
import sys
from doctest import DocTestSuite, ELLIPSIS
from math import pi, isnan
from pkgutil import get_data

from sgp4.api import WGS72OLD, WGS72, WGS84, Satrec, jday, accelerated
from sgp4.earth_gravity import wgs72
from sgp4.ext import invjday, newtonnu, rv2coe
from sgp4.functions import days2mdhms, _day_of_year_to_month_day
from sgp4.propagation import sgp4, sgp4init
from sgp4 import conveniences, io
from sgp4.exporter import export_tle
import sgp4.model as model

_testcase = TestCase('setUp')
assertEqual = _testcase.assertEqual
assertAlmostEqual = _testcase.assertAlmostEqual
assertRaises = _testcase.assertRaises
assertRaisesRegex = getattr(_testcase, 'assertRaisesRegex',
                            _testcase.assertRaisesRegexp)

error = 2e-7
rad = 180.0 / pi
LINE1 = '1 00005U 58002B   00179.78495062  .00000023  00000-0  28098-4 0  4753'
LINE2 = '2 00005  34.2682 348.7242 1859667 331.7664  19.3264 10.82419157413667'
BAD2 = '2 00007  34.2682 348.7242 1859667 331.7664  19.3264 10.82419157413669'
VANGUARD_ATTRS = {
    # Identity
    'satnum': 5,
    'operationmode': 'i',
Ejemplo n.º 34
0
 def __init__(self, *args, **kwargs):
     # This is just to ensure the pytest runs with BF
     # this is done so that base prefixed/suffixed test method don't run
     TestCase.__init__(self, *args, **kwargs)
     BftBaseTest.__init__(self, None, None, None)
Ejemplo n.º 35
0
    from io import StringIO
except ImportError:
    from StringIO import StringIO

import numpy as np

from sgp4.api import WGS72OLD, WGS72, WGS84, Satrec, jday, accelerated
from sgp4.earth_gravity import wgs72
from sgp4.ext import invjday, newtonnu, rv2coe
from sgp4.functions import days2mdhms, _day_of_year_to_month_day
from sgp4.propagation import sgp4, sgp4init
from sgp4 import conveniences, io, omm
from sgp4.exporter import export_omm, export_tle
import sgp4.model as model

_testcase = TestCase('setUp')
_testcase.maxDiff = 9999
assertEqual = _testcase.assertEqual
assertAlmostEqual = _testcase.assertAlmostEqual
assertRaises = _testcase.assertRaises
assertRaisesRegex = getattr(_testcase, 'assertRaisesRegex',
                            _testcase.assertRaisesRegexp)

error = 2e-7
rad = 180.0 / pi
LINE1 = '1 00005U 58002B   00179.78495062  .00000023  00000-0  28098-4 0  4753'
LINE2 = '2 00005  34.2682 348.7242 1859667 331.7664  19.3264 10.82419157413667'
BAD2  = '2 00007  34.2682 348.7242 1859667 331.7664  19.3264 10.82419157413669'
VANGUARD_ATTRS = {
    # Identity
    'satnum': 5,
Ejemplo n.º 36
0
 def setUp(self):
     TestCase.setUp(self)
     global dummyplugin
     dummyplugin = DummyPlugin()
     self.plugin_config = "[plugin:dummy]\nmodule=mr.awsome.tests.test_config.dummyplugin"
Ejemplo n.º 37
0
 def assertEquals(self, *args, **kwargs):
     raise DeprecationWarning(
         'The {0}() function is deprecated. Please start using {1}() '
         'instead.'.format('assertEquals', 'assertEqual')
     )
     return _TestCase.assertEquals(self, *args, **kwargs)
Ejemplo n.º 38
0
 def setUp(self):
     TestCase.setUp(self)
     self.client = Client("testuser", "testapikey")
Ejemplo n.º 39
0
 def setUp(self):
     TestCase.setUp(self)
     self.client_config = self.init_client_config()
Ejemplo n.º 40
0
def verify_false(expr, msg=None):
    """Softly asserts that expression is False."""
    try:
        TestCase(None).assertTrue(expr, msg)
    except AssertionError, e:
        world.verification_errors.append(str(e))
Ejemplo n.º 41
0
 def failIf(self, *args, **kwargs):
     raise DeprecationWarning(
         'The {0}() function is deprecated. Please start using {1}() '
         'instead.'.format('failIf', 'assertFalse')
     )
     return _TestCase.failIf(self, *args, **kwargs)
Ejemplo n.º 42
0
 def setUp(self):
     TestCase.setUp(self)
Ejemplo n.º 43
0
 def failUnlessAlmostEqual(self, *args, **kwargs):
     raise DeprecationWarning(
         'The {0}() function is deprecated. Please start using {1}() '
         'instead.'.format('failUnlessAlmostEqual', 'assertAlmostEqual')
     )
     return _TestCase.failUnlessAlmostEqual(self, *args, **kwargs)
 def __init__(self, *args, **kwargs):
     TestCase.__init__(self, *args, **kwargs)
     # if sys.version_info[0] == 2:
     #     self.assertRegex = self.assertRegexpMatches
     self._init_env()
Ejemplo n.º 45
0
 def __init__(self, *args, **kw):
     TestCase.__init__(self, *args, **kw)
     self.maxDiff = None