Exemple #1
0
        def test_it_matches_the_expected_size(self):
            dummy_frame_name = None

            node = CallGraphNode(frame_name=dummy_frame_name,
                                 class_name=None,
                                 file_path=None,
                                 line_no=None)
            node.increase_runnable_count()

            full_recursive_size_of_node = asizeof.asizeof(node)

            frame_name_size = sys.getsizeof(dummy_frame_name)
            empty_children_tuple_size = sys.getsizeof(())

            assert (MemoryCounter.empty_node_size_bytes == \
                (full_recursive_size_of_node \
                    # The empty size should not include the frame name, so we subtract it

                    - frame_name_size
                    # The empty tuple is always reused by Python, so we also subtract it
                    - empty_children_tuple_size))
Exemple #2
0
    def test_when_a_custom_value_to_add_is_used_it_increases_the_runnable_count_by_the_value_to_add(self):
        subject = CallGraphNode("dummy_frame", class_name=None, file_path=None, line_no=None)
        subject.increase_runnable_count(value_to_add=2)

        assert (subject.runnable_count == 2)
Exemple #3
0
 def test_when_a_custom_value_to_add_is_used_it_raises_a_value_error(self):
     subject = CallGraphNode("dummy_frame", class_name=None, file_path=None, line_no=None)
     with pytest.raises(ValueError):
         subject.increase_runnable_count(value_to_add=-1)
Exemple #4
0
    def test_it_increases_the_runnable_count_by_one(self):
        subject = CallGraphNode("dummy_frame", class_name=None, file_path=None, line_no=None)
        subject.increase_runnable_count()

        assert (subject.runnable_count == 1)