コード例 #1
0
 def test_removes_all_immutable_objects(self):
     obj = create(ImmutableObject)
     call = create(FunctionCall,
                   args={'x': obj},
                   output=obj,
                   definition=create(Function, args=['x']))
     put_on_timeline(obj, call)
     assert_equal([call], remove_objects_unworthy_of_naming([obj, call]))
コード例 #2
0
    def test_keeps_objects_affected_by_side_effects(self):
        output = create(SequenceObject)
        seq = create(SequenceObject, obj=[1])
        call = create(FunctionCall, output=output)
        se = SideEffect([output, seq], [])

        put_on_timeline(seq, se, output, call)

        assert_equal([seq, se, output, call],
                     remove_objects_unworthy_of_naming([seq, se, output, call]))
コード例 #3
0
    def test_removes_objects_only_referenced_by_side_effects(self):
        seq = create(SequenceObject, obj=[1])
        output = create(SequenceObject)
        se = SideEffect([output], [seq])
        call = create(FunctionCall, args={'x': seq}, output=output,
                      definition=create(Function, args=['x']))

        put_on_timeline(seq, output, se, call)

        assert_equal([output, se, call],
                     remove_objects_unworthy_of_naming([seq, output, se, call]))
コード例 #4
0
    def test_keeps_objects_affected_by_side_effects(self):
        output = create(SequenceObject)
        seq = create(SequenceObject, obj=[1])
        call = create(FunctionCall, output=output)
        se = SideEffect([output, seq], [])

        put_on_timeline(seq, se, output, call)

        assert_equal([seq, se, output, call],
                     remove_objects_unworthy_of_naming([seq, se, output,
                                                        call]))
コード例 #5
0
 def test_keeps_objects_used_more_than_once(self):
     alist = create(SequenceObject)
     call = create(FunctionCall,
                   args={
                       'x': alist,
                       'y': alist
                   },
                   definition=create(Function, args=['x', 'y']))
     put_on_timeline(alist, call)
     assert_equal([alist, call],
                  remove_objects_unworthy_of_naming([alist, call]))
コード例 #6
0
    def test_removes_objects_only_referenced_by_side_effects(self):
        seq = create(SequenceObject, obj=[1])
        output = create(SequenceObject)
        se = SideEffect([output], [seq])
        call = create(FunctionCall,
                      args={'x': seq},
                      output=output,
                      definition=create(Function, args=['x']))

        put_on_timeline(seq, output, se, call)

        assert_equal([output, se, call],
                     remove_objects_unworthy_of_naming([seq, output, se,
                                                        call]))
コード例 #7
0
def generate_test_case(testable_interaction, template):
    """This functions binds all other functions from generator submodules
    together (assertions, cleaner, optimizer, objects_namer and builder),
    implementing full test generation process, from a testable interaction
    object to a test case string.

    Call|UserObject|Method|Function -> assertions_for_interaction ->
      [Event] -> remove_objects_unworthy_of_naming ->
        [Event] -> optimize ->
          [Event] -> name_objects_on_timeline ->
            [Event] -> generate_test_contents ->
              CodeString
    """
    return \
        generate_test_contents(
            name_objects_on_timeline(
                optimize(
                    remove_objects_unworthy_of_naming(
                        assertions_for_interaction(testable_interaction)))),
            template)
コード例 #8
0
ファイル: __init__.py プロジェクト: Br3nda/pythoscope
def generate_test_case(testable_interaction, template):
    """This functions binds all other functions from generator submodules
    together (assertions, cleaner, optimizer, objects_namer and builder),
    implementing full test generation process, from a testable interaction
    object to a test case string.

    Call|UserObject|Method|Function -> assertions_for_interaction ->
      [Event] -> remove_objects_unworthy_of_naming ->
        [Event] -> optimize ->
          [Event] -> name_objects_on_timeline ->
            [Event] -> generate_test_contents ->
              CodeString
    """
    return \
        generate_test_contents(
            name_objects_on_timeline(
                optimize(
                    remove_objects_unworthy_of_naming(
                        assertions_for_interaction(testable_interaction)))),
            template)
コード例 #9
0
 def test_removes_all_immutable_objects(self):
     obj = create(ImmutableObject)
     call = create(FunctionCall, args={'x': obj}, output=obj,
                   definition=create(Function, args=['x']))
     put_on_timeline(obj, call)
     assert_equal([call], remove_objects_unworthy_of_naming([obj, call]))
コード例 #10
0
 def test_removes_objects_used_only_once(self):
     alist = create(SequenceObject)
     call = create(FunctionCall, args={'x': alist})
     put_on_timeline(alist, call)
     assert_equal([call], remove_objects_unworthy_of_naming([alist, call]))
コード例 #11
0
 def test_keeps_objects_used_more_than_once(self):
     alist = create(SequenceObject)
     call = create(FunctionCall, args={'x': alist, 'y': alist},
                   definition=create(Function, args=['x', 'y']))
     put_on_timeline(alist, call)
     assert_equal([alist, call], remove_objects_unworthy_of_naming([alist, call]))
コード例 #12
0
 def test_removes_objects_used_only_once(self):
     alist = create(SequenceObject)
     call = create(FunctionCall, args={'x': alist})
     put_on_timeline(alist, call)
     assert_equal([call], remove_objects_unworthy_of_naming([alist, call]))