Exemplo n.º 1
0
    def test_copy(self):
        # copy support is disabled by default in _sre.c
        import re

        p = re.compile("b")
        raises(TypeError, p.__copy__)  # p.__copy__() should raise
        raises(TypeError, p.__deepcopy__)  # p.__deepcopy__() should raise
Exemplo n.º 2
0
def test_surface():
    # TypeError: The Surface type cannot be instantiated
    test.raises(TypeError, "s = cairo.Surface()")

    if cairo.HAS_IMAGE_SURFACE:
        f, w, h = cairo.FORMAT_ARGB32, 100, 100
        s = cairo.ImageSurface(f, w, h)
        assert s.get_format() == f
        assert s.get_width() == w
        assert s.get_height() == h

    if cairo.HAS_PDF_SURFACE:
        f, w, h = tfi.TemporaryFile(mode="w+b"), 100, 100
        s = cairo.PDFSurface(f, w, h)

    if cairo.HAS_PS_SURFACE:
        f, w, h = tfi.TemporaryFile(mode="w+b"), 100, 100
        s = cairo.PSSurface(f, w, h)

    if cairo.HAS_RECORDING_SURFACE:
        s = cairo.RecordingSurface(cairo.CONTENT_COLOR, None)
        s = cairo.RecordingSurface(cairo.CONTENT_COLOR, (1, 1, 10, 10))

    if cairo.HAS_SVG_SURFACE:
        f, w, h = tfi.TemporaryFile(mode="w+b"), 100, 100
        s = cairo.SVGSurface(f, w, h)
Exemplo n.º 3
0
    def test_combo(self):
        x_obj = qterm.Variable('x', pq('obj'))
        x_var = qterm.Variable('x', pq('?a'))
        phi_var = qterm.Constant('phi', pq('?b->bool'))
        phi_obj = qterm.Constant('phi', pq('obj->bool'))
        combo_var = term_builder.build_combination(phi_var, x_var)
        combo_obj = term_builder.build_combination(phi_obj, x_obj)
        combo_var2 = term_builder.build_combination(phi_var, x_obj)

        x, combo = unify_types([x_obj, combo_var])
        assert x == x_obj
        assert combo == combo_obj

        phi_a, phi_b = unify_types([phi_var, phi_obj])
        assert phi_a == phi_var
        assert phi_b == phi_obj

        combo_a, combo_b = unify_types([combo_var, combo_obj])
        assert combo_a == combo_obj
        assert combo_b == combo_obj

        combo_a, combo_b = unify_types([combo_var2, combo_obj])
        assert combo_a == combo_obj
        assert combo_b == combo_obj

        f = qterm.Variable('f', pq('?x->?y'))
        raises(UnificationError, term_builder.build_combination, f, f)
        raises(UnificationError, term_builder.build_combination, x_var, x_var)
Exemplo n.º 4
0
 def test_group(self):
     import re
     m = re.search("a((?P<first>\d)|(?P<second>\s))", "aa1b")
     assert "a1" == m.group()
     assert ("1", "1", None) == m.group(1, 2, 3)
     assert ("1", None) == m.group("first", "second")
     raises(IndexError, m.group, 1, 4)
Exemplo n.º 5
0
def test_choice_loader():
    env = Environment(loader=choice_loader)
    tmpl = env.get_template('justdict.html')
    assert tmpl.render().strip() == 'FOO'
    tmpl = env.get_template('test.html')
    assert tmpl.render().strip() == 'BAR'
    raises(TemplateNotFound, env.get_template, 'missing.html')
Exemplo n.º 6
0
 def test_help(self):
     """tests getting help (returning the help_string so further tests can be done)"""
     stdout = sys.stdout
     helpfile = self.open_testfile("help.txt", "w")
     sys.stdout = helpfile
     try:
         test.raises(SystemExit, self.run_command, help=True)
     finally:
         sys.stdout = stdout
     helpfile.close()
     help_string = self.read_testfile("help.txt")
     print help_string
     convertsummary = self.convertmodule.__doc__.split("\n")[0]
     # the convertsummary might be wrapped. this will probably unwrap it
     assert convertsummary in help_string.replace("\n", " ")
     usageline = help_string[:help_string.find("\n")]
     # Different versions of optparse might contain either upper or 
     # lowercase versions of 'Usage:' and 'Options:', so we need to take 
     # that into account
     assert (usageline.startswith("Usage: ") or usageline.startswith("usage: ")) \
         and "[--version] [-h|--help]" in usageline
     options = help_string[help_string.find("ptions:\n"):]
     options = options[options.find("\n")+1:]
     options = self.help_check(options, "--progress=PROGRESS")
     options = self.help_check(options, "--version")
     options = self.help_check(options, "-h, --help")
     options = self.help_check(options, "--manpage")
     options = self.help_check(options, "--errorlevel=ERRORLEVEL")
     if psyco:
         options = self.help_check(options, "--psyco=MODE")
     options = self.help_check(options, "-i INPUT, --input=INPUT")
     options = self.help_check(options, "-x EXCLUDE, --exclude=EXCLUDE")
     options = self.help_check(options, "-o OUTPUT, --output=OUTPUT")
     return options
Exemplo n.º 7
0
 def test_lost_displayhook(self):
     import sys
     olddisplayhook = sys.displayhook
     del sys.displayhook
     code = compile("42", "<string>", "single")
     raises(RuntimeError, eval, code)
     sys.displayhook = olddisplayhook
Exemplo n.º 8
0
def test_ava_filter_2():
    conf = {
        "default": {
            "lifetime": {"minutes":15},
            "attribute_restrictions": None # means all I have
        },
        "urn:mace:umu.se:saml:roland:sp": {
            "lifetime": {"minutes": 5},
            "attribute_restrictions":{
                "givenName": None,
                "surName": None,
                "mail": [".*@.*\.umu\.se"],
            }
        }}

    policy = Policy(conf)
    
    ava = {"givenName":"Derek", 
            "surName": "Jeter", 
            "mail":"*****@*****.**"}
            
    # I'm filtering away something the SP deems necessary
    
    #policy.filter(ava, 'urn:mace:umu.se:saml:roland:sp', [mail], [gn, sn])
    
    raises(MissingValue, policy.filter, ava, 'urn:mace:umu.se:saml:roland:sp',
                 [mail], [gn, sn])

    ava = {"givenName":"Derek", 
            "surName": "Jeter"}

    # it wasn't there to begin with
    raises(MissingValue, policy.filter, ava, 'urn:mace:umu.se:saml:roland:sp',
                [gn,sn,mail])
Exemplo n.º 9
0
def test_filter_values_req_opt_2():
    r = [
        to_dict(
            Attribute(
                friendly_name="surName",
                name="urn:oid:2.5.4.4",
                name_format="urn:oasis:names:tc:SAML:2.0:attrname-format:uri"),
            ONTS),
        to_dict(
            Attribute(
                friendly_name="givenName",
                name="urn:oid:2.5.4.42",
                name_format="urn:oasis:names:tc:SAML:2.0:attrname-format:uri"),
            ONTS),
        to_dict(
            Attribute(
                friendly_name="mail",
                name="urn:oid:0.9.2342.19200300.100.1.3",
                name_format="urn:oasis:names:tc:SAML:2.0:attrname-format:uri"),
            ONTS)]
    o = [
        to_dict(
            Attribute(
                friendly_name="title",
                name="urn:oid:2.5.4.12",
                name_format="urn:oasis:names:tc:SAML:2.0:attrname-format:uri"),
            ONTS)]

    ava = {"surname": ["Hedberg"], "givenName": ["Roland"],
           "eduPersonAffiliation": ["staff"], "uid": ["rohe0002"]}

    raises(MissingValue, "filter_on_attributes(ava, r, o)")
Exemplo n.º 10
0
    def test_exception_sign_verify_with_cert_from_instance(self):
        assertion = factory(saml.Assertion,
                            version="2.0",
                            id="11100",
                            issue_instant="2009-10-30T13:20:28Z",
                            #signature= sigver.pre_signature_part("11100",
                            # self.sec.my_cert),
                            attribute_statement=do_attribute_statement({
                                ("", "", "surName"): ("Foo", ""),
                                ("", "", "givenName"): ("Bar", ""),
                            })
        )

        response = factory(samlp.Response,
                           assertion=assertion,
                           id="22222",
                           signature=sigver.pre_signature_part("22222",
                                                               self.sec
                                                               .my_cert))

        to_sign = [(class_name(response), response.id)]

        s_response = sigver.signed_instance_factory(response, self.sec, to_sign)

        response2 = response_from_string(s_response)
        # Change something that should make everything fail
        response2.id = "23456"
        raises(sigver.SignatureError, self.sec._check_signature,
               s_response, response2, class_name(response2))
Exemplo n.º 11
0
 def test_unpackiterable(self):
     space = self.space
     w = space.wrap
     l = [space.newlist([]) for l in range(4)]
     w_l = space.newlist(l)
     l1 = space.unpackiterable(w_l)
     l2 = space.unpackiterable(w_l, 4)
     for i in range(4):
         assert space.is_w(l1[i], l[i])
         assert space.is_w(l2[i], l[i])
     err = raises(OperationError, space.unpackiterable, w_l, 3)
     assert err.value.match(space, space.w_ValueError)
     err = raises(OperationError, space.unpackiterable, w_l, 5)
     assert err.value.match(space, space.w_ValueError)
     w_a = space.appexec((), """():
     class A(object):
         def __iter__(self):
             return self
         def next(self):
             raise StopIteration
         def __len__(self):
             1/0
     return A()
     """)
     try:
         space.unpackiterable(w_a)
     except OperationError, o:
         if not o.match(space, space.w_ZeroDivisionError):
             raise Exception("DID NOT RAISE")
def test_ueimporterror():
    ue = uecommunication()
    raises(UeImportError, ue.valid_response, "<Response><Import>Import not ok</Import></Response>")
    assert (
        ue.valid_response("<Response><Import>Import ok</Import></Response>")
        == "<Response><Import>Import ok</Import></Response>"
    )
Exemplo n.º 13
0
def test_creation_fail2():
    """
    Try to create two Managers with the same position.
    This should fail without leaving any partial records in
    the database.

    """
    setupClass([DIManager, DIEmployee, DIPerson])

    kwargs = {'firstName': 'John', 'lastName': 'Doe',
              'position': 'Project Manager'}
    DIManager(**kwargs)
    persons = DIEmployee.select(DIPerson.q.firstName == 'John')
    assert persons.count() == 1

    kwargs = {'firstName': 'John', 'lastName': 'Doe II',
              'position': 'Project Manager'}
    raises(Exception, DIManager, **kwargs)
    persons = DIPerson.select(DIPerson.q.firstName == 'John')
    assert persons.count() == 1

    if not supports('transactions'):
        skip("Transactions aren't supported")
    transaction = DIPerson._connection.transaction()
    kwargs = {'firstName': 'John', 'lastName': 'Doe III',
              'position': 'Project Manager'}
    raises(Exception, DIManager, connection=transaction, **kwargs)
    transaction.rollback()
    transaction.begin()
    persons = DIPerson.select(DIPerson.q.firstName == 'John',
                              connection=transaction)
    assert persons.count() == 1
Exemplo n.º 14
0
 def test_cjk(self):
     import sys
     import unicodedata
     cases = ((0x3400, 0x4DB5),
              (0x4E00, 0x9FA5))
     if unicodedata.unidata_version >= "4.1":
         cases = ((0x3400, 0x4DB5),
                  (0x4E00, 0x9FBB),
                  (0x20000, 0x2A6D6))
     for first, last in cases:
         # Test at and inside the boundary
         for i in (first, first + 1, last - 1, last):
             charname = 'CJK UNIFIED IDEOGRAPH-%X'%i
             char = ('\\U%08X' % i).decode('unicode-escape')
             assert unicodedata.name(char) == charname
             assert unicodedata.lookup(charname) == char
         # Test outside the boundary
         for i in first - 1, last + 1:
             charname = 'CJK UNIFIED IDEOGRAPH-%X'%i
             char = ('\\U%08X' % i).decode('unicode-escape')
             try:
                 unicodedata.name(char)
             except ValueError, e:
                 assert e.message == 'no such name'
             raises(KeyError, unicodedata.lookup, charname)
Exemplo n.º 15
0
    def test_copy(self):
        import re

        # copy support is disabled by default in _sre.c
        m = re.match("bla", "bla")
        raises(TypeError, m.__copy__)
        raises(TypeError, m.__deepcopy__)
    def test_no_2nd_arg_and_1st_isnt_enough_for_mkv(self, p):
        s = """
        name = s
        key_format =     16s
        type = HashIndex
        hash_lim = 1
        make_key_value:
        0
        """
        with raises(IndexCreatorValueException):
            p.parse(s, 'TestIndex')

        s2 = """
        name = s
        key_format =     16s
        type = HashIndex
        hash_lim = 1
        make_key_value:
        "aaa"
        """
        with raises(IndexCreatorValueException):
            p.parse(s2, 'TestIndex')

        s3 = """
        name = s
        key_format =     16s
        type = HashIndex
        hash_lim = 1
        make_key_value:
        md5(a)
        """
        with raises(IndexCreatorValueException):
            p.parse(s3, 'TestIndex')
Exemplo n.º 17
0
def test_ava_filter_2():
    conf = {
        "default": {
            "lifetime": {"minutes": 15},
            "attribute_restrictions": None  # means all I have
        },
        "urn:mace:umu.se:saml:roland:sp": {
            "lifetime": {"minutes": 5},
            "attribute_restrictions": {
                "givenName": None,
                "surName": None,
                "mail": [".*@.*\.umu\.se"],
            }
        }}

    policy = Policy(conf)

    ava = {"givenName": "Derek",
           "surName": "Jeter",
           "mail": "*****@*****.**"}

    # mail removed because it doesn't match the regular expression
    # So this should fail.
    raises(MissingValue, policy.filter, ava, 'urn:mace:umu.se:saml:roland:sp',
           None, [mail], [gn, sn])

    ava = {"givenName": "Derek",
           "surName": "Jeter"}

    # it wasn't there to begin with
    raises(Exception, policy.filter, ava, 'urn:mace:umu.se:saml:roland:sp',
           None, [gn, sn, mail])
    def test_too_much_colons(self, p):
        s = """
        name = s
        key_format =     32s
        type = HashIndex
        hash_lim = 1
        make_key_value:
        1<=2:1:1,None
        make_key:
        1"""
        with raises(IndexCreatorFunctionException):
            p.parse(s, 'TestIndex')
        s2 = """
        name = s
        key_format =     32s
        type = HashIndex
        hash_lim = 1
        make_key_value:
        1<=2:1,None
        make_key:
        a>1::"""
        with raises(IndexCreatorFunctionException):
            p.parse(s2, 'TestIndex')

        s3 = """
        name = s
        key_format =     : 32s
        type = HashIndex
        hash_lim = 1
        make_key_value:
        1<=2:1,None
        make_key:
        a>1:1"""
        with raises(IndexCreatorValueException):
            p.parse(s3, 'TestIndex')
Exemplo n.º 19
0
 def test_setcheckinterval(self):
     import sys
     raises(TypeError, sys.setcheckinterval)
     orig = sys.getcheckinterval()
     for n in 0, 100, 120, orig: # orig last to restore starting state
         sys.setcheckinterval(n)
         assert sys.getcheckinterval() == n
Exemplo n.º 20
0
    def test_logout_2(self):
        """ one IdP/AA with BINDING_SOAP, can't actually send something"""

        conf = config.SPConfig()
        conf.load_file("server2_conf")
        client = Saml2Client(conf)

        # information about the user from an IdP
        session_info = {
            "name_id": "123456",
            "issuer": "urn:mace:example.com:saml:roland:idp",
            "not_on_or_after": in_a_while(minutes=15),
            "ava": {
                "givenName": "Anders",
                "surName": "Andersson",
                "mail": "*****@*****.**"
            }
        }
        client.users.add_information_about_person(session_info)
        entity_ids = self.client.users.issuers_of_info("123456")
        assert entity_ids == ["urn:mace:example.com:saml:roland:idp"]
        destinations = client.config.single_logout_services(entity_ids[0],
                                                            BINDING_SOAP)
        print destinations
        assert destinations == ['http://localhost:8088/slo']

        # Will raise an error since there is noone at the other end.
        raises(LogoutError, 'client.global_logout("123456", "Tired", in_a_while(minutes=5))')
Exemplo n.º 21
0
    def test_fill_in_start_end(self):
        # case where neither start nor end is defined; they are returned
        # as is (as None values)
        s = e = None
        assert (None, None) == self.arl_indexer._fill_in_start_end(s, e)

        # case where end is defined but start isn't (invalid); exception raised
        e = datetime.datetime.utcnow()
        with raises(ValueError) as e_info:
            self.arl_indexer._fill_in_start_end(s, e)
        assert arlindexer.ArlIndexer.END_WITHOUT_START_ERR_MSG == e_info.value.args[0]

        # case where start is after end (invalid); exception raised
        s = e + datetime.timedelta(1)
        with raises(ValueError) as e_info:
            self.arl_indexer._fill_in_start_end(s, e)
        assert arlindexer.ArlIndexer.START_AFTER_END_ERR_MSG == e_info.value.args[0]

        # case where start is before end (valid); they are returned as is
        s = e - datetime.timedelta(1)
        assert s, e == self.arl_indexer._fill_in_start_end(s, e)

        # case where start is defined but not end; end gets set to now
        with timecop.freeze(time.mktime(e.timetuple())):
            assert s, e == self.arl_indexer._fill_in_start_end(s, None)
Exemplo n.º 22
0
def test():
    for puzzle in puzzles.itervalues():
        puzzle = load(puzzle)
        puzzle.solve()
        assert puzzle.is_solved()
    for puzzle in bad_puzzles.itervalues():
        raises(InconsistentPuzzleError, load(puzzle).solve)
Exemplo n.º 23
0
def test_prefix_loader():
    env = Environment(loader=prefix_loader)
    tmpl = env.get_template('a/test.html')
    assert tmpl.render().strip() == 'BAR'
    tmpl = env.get_template('b/justdict.html')
    assert tmpl.render().strip() == 'FOO'
    raises(TemplateNotFound, env.get_template, 'missing')
Exemplo n.º 24
0
 def test_cjk(self):
     import sys
     if sys.maxunicode < 0x10ffff:
         skip("requires a 'wide' python build.")
     import unicodedata
     cases = ((0x3400, 0x4DB5),
              (0x4E00, 0x9FA5))
     if unicodedata.unidata_version >= "4.1":
         cases = ((0x3400, 0x4DB5),
                  (0x4E00, 0x9FBB),
                  (0x20000, 0x2A6D6))
     for first, last in cases:
         # Test at and inside the boundary
         for i in (first, first + 1, last - 1, last):
             charname = 'CJK UNIFIED IDEOGRAPH-%X'%i
             assert unicodedata.name(unichr(i)) == charname
             assert unicodedata.lookup(charname) == unichr(i)
         # Test outside the boundary
         for i in first - 1, last + 1:
             charname = 'CJK UNIFIED IDEOGRAPH-%X'%i
             try:
                 unicodedata.name(unichr(i))
             except ValueError:
                 pass
             raises(KeyError, unicodedata.lookup, charname)
Exemplo n.º 25
0
def test_filesystem_loader():
    env = Environment(loader=filesystem_loader)
    tmpl = env.get_template('test.html')
    assert tmpl.render().strip() == 'BAR'
    tmpl = env.get_template('foo/test.html')
    assert tmpl.render().strip() == 'FOO'
    raises(TemplateNotFound, env.get_template, 'missing.html')
Exemplo n.º 26
0
    def test_finditer(self):
        import re

        it = re.finditer("b(.)", "brabbel")
        assert "br" == it.next().group(0)
        assert "bb" == it.next().group(0)
        raises(StopIteration, it.next)
Exemplo n.º 27
0
def test_coordinate_attribute_assignment_01( ):
    '''Coordinates are immutable.
    Attributes cannot be set (rebound).'''
    t = Coordinate(1, 2)
    assert raises(AttributeError, 't.xy = 2')
    assert raises(AttributeError, 't.foo = 3')
    assert raises(TypeError, 't[0] = 2')
Exemplo n.º 28
0
 def test_unpackiterable(self):
     space = self.space
     w = space.wrap
     l = [w(1), w(2), w(3), w(4)]
     w_l = space.newlist(l)
     assert space.unpackiterable(w_l) == l
     assert space.unpackiterable(w_l, 4) == l
     err = raises(OperationError, space.unpackiterable, w_l, 3)
     assert err.value.match(space, space.w_ValueError)
     err = raises(OperationError, space.unpackiterable, w_l, 5)
     assert err.value.match(space, space.w_ValueError)
     w_a = space.appexec((), """():
     class A(object):
         def __iter__(self):
             return self
         def next(self):
             raise StopIteration
         def __len__(self):
             1/0
     return A()
     """)
     try:
         space.unpackiterable(w_a)
     except OperationError, o:
         if not o.match(space, space.w_ZeroDivisionError):
             raise Exception("DID NOT RAISE")
Exemplo n.º 29
0
def test_begin_twice():
    transaction = Transaction(Collection([]))
    transaction.begin()
    raises(TransactionAlreadyActiveError, transaction.begin)

    # no exception raised if transaction is already finished
    transaction.rollback()
    transaction.begin()
Exemplo n.º 30
0
 def test_basic(self):
     self.o.ind = -2
     self.n.ind = 2
     import operator
     assert operator.index(self.o) == -2
     assert operator.index(self.n) == 2
     raises(TypeError, operator.index, self.o_no_index) 
     raises(TypeError, operator.index, self.n_no_index) 
def test_parse_problem_name_fail():
    test = ['(domain test)']
    iter = parse_lisp_iterator(test)
    with raises(ValueError):
        parse_problem_name(iter)
def test_parseRequirements2():
    test = ['(:predicates :name :parameters :foo )']
    iter = parse_lisp_iterator(test)
    with raises(ValueError):
        parse_requirements_stmt(iter)
def test_parseParameters2():
    test = ['(:predicates ( ?x - block ?y - foo ?z - block  ))']
    iter = parse_lisp_iterator(test)
    with raises(ValueError):
        parse_parameters(iter)
Exemplo n.º 34
0
 def test_no_location(self):
     with raises(ValueError) as e:
         self.estimator.estimate({'activity':[{}]})
Exemplo n.º 35
0
 def test_empty_lookup_info(self):
     self.estimator.lookup.look_up = lambda p: {}
     with raises(RuntimeError) as e:
         self.estimator.estimate(self.active_area_location)
Exemplo n.º 36
0
def test_global_id_invalid():
    field = GlobalIDFormField()
    with raises(ValidationError):
        field.clean('badvalue')
Exemplo n.º 37
0
def test_global_id_bad_int():
    field = GlobalIDFormField()
    with raises(ValidationError):
        field.clean('TXlUeXBlOmFiYw==')
Exemplo n.º 38
0
def test_coordinate__init__06():
    '''Coordinate cannot be initialized with a triple.'''
    assert raises(TypeError, 't = Coordinate((1, 2, 3))')
Exemplo n.º 39
0
def test_coordinate__init__07():
    '''Coordinate cannot be initialized with a Path.'''
    assert raises(TypeError, 't = Coordinate(Path([1,2]))')
Exemplo n.º 40
0
def test_should_unknown_django_field_raise_exception():
    with raises(Exception) as excinfo:
        convert_django_field(None)
    assert "Don't know how to convert the Django field" in str(excinfo.value)
Exemplo n.º 41
0
def test_dependency():

    dep = Dependency('test_module')

    with raises(ImportError):
        dep.method_call
Exemplo n.º 42
0
def test_field_no_contributed_raises_error():
    f = Field(GraphQLString)
    with raises(Exception):
        schema.T(f)
Exemplo n.º 43
0
def test_should_unknown_sqlalchemy_field_raise_exception():
    with raises(Exception) as excinfo:
        convert_sqlalchemy_column(None)
    assert "Don't know how to convert the SQLAlchemy field" in str(
        excinfo.value)
Exemplo n.º 44
0
def test_schema_no_query():
    schema = Schema(name='My own schema')
    with raises(Exception) as excinfo:
        schema.schema
    assert 'define a base query type' in str(excinfo)
Exemplo n.º 45
0
def test_coordinate__div__03():
    '''A Coordinate cannot be divided by a Coordinate.'''
    a = Coordinate(1, 2)
    b = Coordinate(2, 4)
    assert raises(TypeError, 't = a / b')
Exemplo n.º 46
0
def test_coordinate__getitem__01():
    t = Coordinate(1, 2)
    assert t[0] == 1
    assert t[1] == 2
    assert raises(IndexError, 't[3]')
Exemplo n.º 47
0
def test_global_id_none():
    field = GlobalIDFormField()
    with raises(ValidationError):
        field.clean(None)
Exemplo n.º 48
0
def test_coordinate__init__03():
    '''Coordinate cannot be initialized with a Coordinate.'''
    ##In this case, the constructor returns the existing coordinate.'''
    a = Coordinate(1, 2)
    assert raises(TypeError, 't = Coordinate(a)')
Exemplo n.º 49
0
 def test_lookup_info_percentages_greater_than_100(self):
     self.estimator.lookup.look_up = lambda p: FUELBED_INFO_60_40_10
     with raises(RuntimeError) as e:
         self.estimator.estimate(self.active_area_location)
Exemplo n.º 50
0
def test_coordinate__floordiv__04():
    '''Floor Division raises an OperandError on wrong type.'''
    a = Coordinate(1, 2)
    assert raises(TypeError, 'a // (1, 2, 3)')
Exemplo n.º 51
0
 def test_no_geojson_or_lat_or_lng(self):
     with raises(ValueError) as e:
         self.estimator.estimate({"activity":[{"location":{}}]})
Exemplo n.º 52
0
def test_coordinate__floordiv__03():
    '''Denominator 0 raises ZeroDivisionError.'''
    a = Coordinate(1, 2)
    assert raises(ZeroDivisionError, 't = a // 0')
Exemplo n.º 53
0
 def test_no_activity(self):
     with raises(ValueError) as e:
         self.estimator.estimate({})
Exemplo n.º 54
0
def test_coordinate__floordiv__02():
    '''Floor division does not work with two Coordinates.'''
    a = Coordinate(1, 2)
    b = Coordinate(2, -4)
    assert raises(TypeError, 't = a // b')
Exemplo n.º 55
0
def test_coordinate__init__02():
    '''Coordinate cannot be initialized with a duple.'''
    assert raises(TypeError, 'Coordinate((1, 2))')
Exemplo n.º 56
0
def test_coordinate__div__05():
    '''Division raises an Error on wrong type.'''
    a = Coordinate(1, 2)
    assert raises(TypeError, 'a / (1, 2, 3)')
def test_parse_goal_stmt_fail():
    test = ['(:init ssdfsdf)']
    iter = parse_lisp_iterator(test)
    with raises(ValueError):
        parse_goal_stmt(iter)
Exemplo n.º 58
0
def test_coordinate__div__04():
    '''A Coordinate cannot be divided by a duple.'''
    a = Coordinate(1, 2)
    b = (2, 4)
    assert raises(TypeError, 'a / b')
Exemplo n.º 59
0
def test_get_unregistered_type():
    with raises(Exception) as excinfo:
        schema.get_type('NON_EXISTENT_MODEL')
    assert 'not found' in str(excinfo.value)
Exemplo n.º 60
0
def test_deprecated_plugins_throws_exception():
    with raises(Exception) as excinfo:
        Schema(plugins=[])
    assert 'Plugins are deprecated, please use middlewares' in str(excinfo.value)