Exemple #1
0
 def test_invalid_shell(self, build_script):
     with raises(ValueError) as exc_info:
         build_script([], 'command', 'nosuchsh')
     assert_exc_info_msg(
         exc_info,
         "invalid shell syntax 'nosuchsh', valid syntaxes are "
         "'bash', 'zsh', 'tcsh', 'ksh', 'python'")
Exemple #2
0
 def test_raises_error_on_nonexistent_component_type(
         self, manager, entities, components, component_types):
     with raises(NonexistentComponentTypeForEntity) as exc_info:
         manager.component_for_entity(entities[3], component_types[1])
     assert_exc_info_msg(
         exc_info,
         "Nonexistent component type: "
         "`Component1' for entity: `Entity(3)'")
Exemple #3
0
 def test_raises_error_on_nonexistent_component_type(
         self, manager, entities, components, component_types):
     with raises(NonexistentComponentTypeForEntity) as exc_info:
         manager.component_for_entity(entities[3], component_types[1])
     assert_exc_info_msg(
         exc_info,
         "Nonexistent component type: "
         "`Component1' for entity: `Entity(3)'")
    def test_inconsistent_dims(self):
        with raises(InconsistentMatrixDimensions) as exc_info:
            from_string('''34 5
2
''')
        assert_exc_info_msg(
            exc_info,
            'Inconsistent columns in current row (1) '
            'from those in the first row (2)')
 def test_end_of_one_line_program(self):
     with raises(ParseError) as exc_info:
         parse(
             mkiter(
                 [
                     lit("STO"),
                     ("POS_INT", "37"),
                     # STO is missing a REAL argument
                 ]
             )
         )
     assert_exc_info_msg(exc_info, "Unexpected `$end'")
 def test_sto_neg_index(self):
     with raises(ParseError) as exc_info:
         parse(
             mkiter(
                 [
                     lit("STO"),
                     # STO should only take a POS_INT argument here.
                     ("NEG_INT", "-37"),
                     ("REAL", "42.4"),
                 ]
             )
         )
     assert_exc_info_msg(exc_info, "Unexpected `NEG_INT'")
 def test_missing_arg(self):
     with raises(ParseError) as exc_info:
         parse(
             mkiter(
                 [
                     lit("STO"),
                     ("POS_INT", "37"),
                     ("POS_INT", "45"),
                     lit("PR"),
                     # PR is missing a POS_INT argument
                     lit("PR"),
                     ("POS_INT", "37"),
                 ]
             )
         )
     assert_exc_info_msg(exc_info, "Unexpected `PR'")
 def test_even_dimension(self):
     with raises(InvalidStencilDimensionsError) as exc_info:
         apply_stencil(Matrix(2, 2, range(4)), Matrix(4, 4, range(16)))
     assert_exc_info_msg(
         exc_info, 'Invalid odd dimensions for stencil: (2, 2)')
Exemple #9
0
 def test_raises_error(self, manager, systems):
     with raises(DuplicateSystemTypeError) as exc_info:
         manager.add_system(systems[1])
     assert_exc_info_msg(
         exc_info, "Duplicate system type: `System1'")
 def test_negative_error(self, mat):
     with raises(ValueError) as exc_info:
         mat.getitem([-1, 5])
     assert_exc_info_msg(
         exc_info, 'Matrix indices must be non-negative. '
         "Use `getitem_wraparound' for wrap-around behavior.")
 def test_bne_real_offset(self):
     with raises(ParseError) as exc_info:
         parse(mkiter([lit("BNE"), ("POS_INT", "81"), ("POS_INT", "32"), ("REAL", "-21.2")]))
     assert_exc_info_msg(exc_info, "Unexpected `REAL'")
 def test_neg_dimension(self):
     with raises(ParseError) as exc_info:
         parse(mkiter([lit("CMX"), ("POS_INT", "11"), ("POS_INT", "12"), ("NEG_INT", "-13")]))
     assert_exc_info_msg(exc_info, "Unexpected `NEG_INT'")
 def test_negative_matrix_index(self):
     with raises(ParseError) as exc_info:
         parse(mkiter([lit("CMX"), ("NEG_INT", "-22"), ("POS_INT", "20"), ("POS_INT", "20")]))
     assert_exc_info_msg(exc_info, "Unexpected `NEG_INT'")
 def test_raises_on_invalid_type(self):
     error = UninitializedVariableError('Invalid', 20)
     with raises(TypeError) as exc_info:
         str(error)
     assert_exc_info_msg(exc_info, 'Invalid variable type: Invalid')
 def test_str(self, mat):
     with raises(TypeError) as exc_info:
         mat.getitem('abcd')
     assert_exc_info_msg(
         exc_info,
         'Matrix indices must be a list of integers of length 2')
Exemple #16
0
 def test_raises_error(self, manager, systems):
     with raises(DuplicateSystemTypeError) as exc_info:
         manager.add_system(systems[1])
     assert_exc_info_msg(
         exc_info, "Duplicate system type: `System1'")
Exemple #17
0
 def test_invalid_shell(self, build_script):
     with raises(ValueError) as exc_info:
         build_script([], 'command', 'nosuchsh')
     assert_exc_info_msg(
         exc_info, "invalid shell syntax 'nosuchsh', valid syntaxes are "
         "'bash', 'zsh', 'tcsh', 'ksh', 'python'")