Ejemplo n.º 1
0
    def test_when_frame_name_is_different_it_returns_a_new_child_node(self):
        existing_node = self.subject.update_current_node_and_get_child(
            Frame("new_child_frame_1"))
        new_node = self.subject.update_current_node_and_get_child(
            Frame("new_child_frame_2"))

        assert (existing_node is not new_node)
Ejemplo n.º 2
0
    def test_it_includes_correct_file_path_when_available_on_non_Windows_system(
            self):
        self.profile.add(
            Sample(stacks=[[
                Frame("bottom_with_path", file_path="path/file1.py"),
                Frame("middle_with_path", file_path="path/file2.py"),
                Frame("top_without_path")
            ]]))

        assert (self.decoded_json_result()["callgraph"]["children"]
                ["path.file1:bottom_with_path"] == {
                    "children": {
                        "path.file2:middle_with_path": {
                            "children": {
                                "top_without_path": {
                                    "counts": {
                                        "WALL_TIME": 1
                                    }
                                }
                            },
                            'file': 'path/file2.py'
                        }
                    },
                    'file': 'path/file1.py'
                })
Ejemplo n.º 3
0
    def test_it_handles_unicode_escape_correctly_on_Windows(self):
        self.profile.add(
            Sample(stacks=[[
                Frame("bottom_with_path"),
                Frame("middle",
                      file_path="C:/User/ironman/path/xs.py",
                      class_name="ClassA"),
                Frame("top",
                      file_path="C:\\User\\ironman\\path\\xs.py",
                      class_name="ClassA")
            ]]))

        assert (self.decoded_json_result()["callgraph"]["children"]
                ["bottom_with_path"] == {
                    "children": {
                        "User.ironman.path.xs:ClassA:middle": {
                            "children": {
                                "User.ironman.path.xs:ClassA:top": {
                                    "file": "C:\\User\\ironman\\path\\xs.py",
                                    "counts": {
                                        "WALL_TIME": 1
                                    }
                                }
                            },
                            "file": "C:\\User\\ironman\\path\\xs.py"
                        }
                    }
                })
Ejemplo n.º 4
0
    def test_when_file_path_is_different_it_returns_a_new_child_node(self):
        existing_node = self.subject.update_current_node_and_get_child(
            Frame("new_child_frame", file_path="file_path/file1.py"))
        new_node = self.subject.update_current_node_and_get_child(
            Frame("new_child_frame", class_name="file_path/file2.py"))

        assert (existing_node is not new_node)
    def test_it_keeps_the_total_sum_of_the_seen_threads_count_values(self):
        sample1 = Sample(stacks=[[Frame("frame1")]], seen_threads_count=56)
        sample2 = Sample(stacks=[[Frame("frame1")]], seen_threads_count=78)

        self.subject.add(sample1)
        self.subject.add(sample2)

        assert (self.subject.total_seen_threads_count == (56 + 78))
Ejemplo n.º 6
0
        def test_when_line_no_existed_before_it_does_not_update_line_no(self):
            self.subject.update_current_node_and_get_child(
                Frame("new_child_frame", file_path="file_path/file.py", line_no=100))

            node = self.subject.update_current_node_and_get_child(
                Frame("new_child_frame", file_path="file_path/file.py", line_no=None))

            assert (node.start_line == 100)
            assert (node.end_line == 100)
Ejemplo n.º 7
0
    def test_when_line_no_needs_to_be_updated_it_takes_the_largest_end_line_no(self):
        self.subject.update_current_node_and_get_child(
            Frame("new_child_frame", file_path="file_path/file.py", line_no=200))

        node = self.subject.update_current_node_and_get_child(
            Frame("new_child_frame", file_path="file_path/file.py", line_no=234))

        assert (node.start_line == 200)
        assert (node.end_line == 234)
Ejemplo n.º 8
0
    def test_insert_already_exist_child_does_not_call_memory_counter(self):
        mock_memory_counter = _mock_memory_counter()
        call_graph_node = CallGraphNode("foo", class_name=None, file_path=None, line_no=None,
                                        memory_counter=mock_memory_counter)
        call_graph_node.update_current_node_and_get_child(Frame("new_child_frame"))
        mock_memory_counter.reset_mock()

        call_graph_node.update_current_node_and_get_child(Frame("new_child_frame"))

        mock_memory_counter.assert_not_called()
Ejemplo n.º 9
0
    def test_insert_extra_child_calls_memory_counter(self):
        mock_memory_counter = _mock_memory_counter()
        call_graph_node = CallGraphNode("foo", class_name=None, file_path=None, line_no=None,
                                        memory_counter=mock_memory_counter)
        call_graph_node.update_current_node_and_get_child(Frame("new_child_frame_1"))
        mock_memory_counter.reset_mock()

        call_graph_node.update_current_node_and_get_child(Frame("new_child_frame_2"))

        mock_memory_counter.count_first_child.assert_not_called()
        mock_memory_counter.count_add_child.assert_called_once()
    def test_it_keeps_the_total_sum_of_the_attempted_sample_threads_count_values(
            self):
        sample1 = Sample(stacks=[[Frame("frame1")]],
                         attempted_sample_threads_count=12)
        sample2 = Sample(stacks=[[Frame("frame1")]],
                         attempted_sample_threads_count=34)

        self.subject.add(sample1)
        self.subject.add(sample2)

        assert (self.subject.total_attempted_sample_threads_count == (12 + 34))
Ejemplo n.º 11
0
        def test_it_matches_the_expected_size(self):
            node = CallGraphNode(frame_name=None,
                                 class_name=None,
                                 file_path=None,
                                 line_no=None)

            node.update_current_node_and_get_child(Frame("child1"))
            one_child_storage_size = asizeof.asizeof(node.children, limit=0)

            node.update_current_node_and_get_child(Frame("child2"))
            two_children_storage_size = asizeof.asizeof(node.children, limit=0)

            assert (MemoryCounter.storage_increment_size_bytes == (
                two_children_storage_size - one_child_storage_size))
Ejemplo n.º 12
0
def example_profile():
    start_time = 1514764800000
    end_time = 1514772000000
    profile = Profile(profiling_group_name="TestProfilingGroupName",
                      sampling_interval_seconds=1.0,
                      host_weight=2,
                      start=start_time,
                      clock=lambda: 1514772000000)
    profile.add(
        Sample(
            stacks=[[Frame("bottom"),
                     Frame("middle"),
                     Frame("top")],
                    [Frame("bottom"),
                     Frame("middle"),
                     Frame("different_top")],
                    [Frame("bottom"), Frame("middle")]],
            attempted_sample_threads_count=10,
            seen_threads_count=15))
    profile.end = end_time
    profile.set_overhead_ms(timedelta(milliseconds=256))
    if platform.system() == "Windows":
        # In Windows, as time.process stays constant if no cpu time was used (https://bugs.python.org/issue37859), we
        # would need to manually override the cpu_time_seconds to ensure the test runs as expected
        profile.cpu_time_seconds = 0.123
    return profile
Ejemplo n.º 13
0
    def before(self):
        now_millis = int(time.time()) * 1000
        five_minutes_ago_millis = now_millis - (5 * 60 * 1000)
        sample = Sample(
            stacks=[[Frame(MY_PROFILING_GROUP_NAME_FOR_INTEG_TESTS)]],
            attempted_sample_threads_count=1,
            seen_threads_count=1)

        self.profile = Profile(MY_PROFILING_GROUP_NAME_FOR_INTEG_TESTS, 1.0,
                               1.0, five_minutes_ago_millis)
        # FIXME: Remove adding the end time manually below after feature fully support
        self.profile.end = now_millis
        self.profile.add(sample)

        self.environment = {
            "should_profile": True,
            "profiling_group_name": MY_PROFILING_GROUP_NAME_FOR_INTEG_TESTS,
            "aws_session": boto3.session.Session(),
            "reporting_interval": timedelta(minutes=13),
            "sampling_interval": timedelta(seconds=1),
            "minimum_time_reporting": timedelta(minutes=6),
            "max_stack_depth": 2345,
            "cpu_limit_percentage": 29,
            "agent_metadata": AgentMetadata(fleet_info=DefaultFleetInfo())
        }
        self.environment["codeguru_profiler_builder"] = CodeGuruClientBuilder(
            self.environment)
        self.agent_config = AgentConfiguration(
            should_profile=True,
            sampling_interval=self.environment["sampling_interval"],
            reporting_interval=self.environment["reporting_interval"],
            minimum_time_reporting=self.environment["minimum_time_reporting"],
            max_stack_depth=self.environment["max_stack_depth"],
            cpu_limit_percentage=self.environment["cpu_limit_percentage"])
    def test_it_returns_the_average_thread_weight_for_the_samples_in_the_profile(
            self):
        sample = Sample(stacks=[[Frame("frame1")]],
                        attempted_sample_threads_count=10,
                        seen_threads_count=15)

        self.subject.add(sample)

        assert (self.subject.average_thread_weight() == 1.5)
Ejemplo n.º 15
0
    def test_it_handles_unicode_escape_correctly_on_non_Windows_system(self):
        self.profile.add(
            Sample(stacks=[[
                Frame("bottom_with_path"),
                Frame("top",
                      file_path="C:\\User\\ironman\\path\\xs.py",
                      class_name="ClassA")
            ]]))

        assert (self.decoded_json_result()["callgraph"]["children"]
                ["bottom_with_path"] == {
                    "children": {
                        "C:\\User\\ironman\\path\\xs:ClassA:top": {
                            'file': 'C:\\User\\ironman\\path\\xs.py',
                            "counts": {
                                "WALL_TIME": 1
                            }
                        }
                    }
                })
Ejemplo n.º 16
0
    def test_when_child_node_with_frame_does_not_exist__it_returns_a_new_child_node_for_the_given_frame(
            self):
        new_child_node = self.subject.update_current_node_and_get_child(
            Frame("new_child_frame", class_name="TestClass", file_path="file_path/file.py", line_no=123))

        assert (new_child_node.frame_name == "new_child_frame")
        assert (new_child_node.class_name == "TestClass")
        assert (new_child_node.file_path == "file_path/file.py")
        assert (new_child_node.start_line == 123)
        assert (new_child_node.end_line == 123)
        assert (new_child_node.runnable_count == 0)
Ejemplo n.º 17
0
    def test_it_includes_line_when_available(self):
        self.profile.add(
            Sample(stacks=[[
                Frame("bottom_with_line_no", line_no=123),
                Frame("middle_with_line_no", line_no=234),
                Frame("top_without_line_no")
            ],
                           [
                               Frame("bottom_with_line_no", line_no=123),
                               Frame("middle_with_line_no", line_no=345),
                               Frame("top_without_line_no")
                           ]]))

        assert (self.decoded_json_result()["callgraph"]["children"]
                ["bottom_with_line_no"] == {
                    "children": {
                        "middle_with_line_no": {
                            "children": {
                                "top_without_line_no": {
                                    "counts": {
                                        "WALL_TIME": 2
                                    }
                                }
                            },
                            "line": [234, 345]
                        }
                    },
                    "line": [123]
                })
Ejemplo n.º 18
0
    def test_it_handles_unicode_frames_correctly(self):
        self.profile.add(
            Sample(stacks=[[
                Frame("unicode_bottom"),
                Frame(u"😉"),
                Frame(u"🙃")
            ]]))

        assert (self.decoded_json_result()["callgraph"]["children"]
                ["unicode_bottom"] == {
                    "children": {
                        u"😉": {
                            "children": {
                                u"🙃": {
                                    "counts": {
                                        "WALL_TIME": 1
                                    }
                                }
                            }
                        }
                    }
                })
Ejemplo n.º 19
0
    def test_it_includes_class_name_when_available(self):
        self.profile.add(
            Sample(stacks=[[
                Frame("bottom_with_path", class_name="ClassA"),
                Frame("middle_with_path", class_name="ClassB"),
                Frame("top_without_path")
            ]]))

        assert (self.decoded_json_result()["callgraph"]["children"]
                ["ClassA:bottom_with_path"] == {
                    "children": {
                        "ClassB:middle_with_path": {
                            "children": {
                                "top_without_path": {
                                    "counts": {
                                        "WALL_TIME": 1
                                    }
                                }
                            }
                        }
                    }
                })
Ejemplo n.º 20
0
        def test_it_matches_the_expected_size(self):
            node = CallGraphNode(frame_name=None,
                                 class_name=None,
                                 file_path=None,
                                 line_no=None)
            node.update_current_node_and_get_child(frame=Frame(None))

            recursive_node_storage_size = asizeof.asizeof(node.children)
            child_node_size = asizeof.asizeof(
                CallGraphNode(frame_name=None,
                              class_name=None,
                              file_path=None,
                              line_no=None))

            assert (MemoryCounter.base_storage_size_bytes == (
                recursive_node_storage_size - child_node_size))
Ejemplo n.º 21
0
def _maybe_add_boto_operation_name(raw_frame, result):
    """
    boto is dealing with API calls in a very generic way so by default the sampling
    would only show that we are making an api call without having the actual operation name.
    This function checks if this frame is botocore.client.py:_api_call and if it is, it adds
    a frame with the actual operation name.
    :param raw_frame: the raw frame
    """
    if (raw_frame.f_code.co_name == '_api_call'
            and BOTO_CLIENT_PATH.search(raw_frame.f_code.co_filename) is not None
            and raw_frame.f_locals and 'py_operation_name' in raw_frame.f_locals.keys()
            and raw_frame.f_locals.get('py_operation_name')):
        result.append(
            Frame(name=raw_frame.f_locals.get('py_operation_name'),
                  class_name=_extract_class(raw_frame.f_locals),
                  file_path=raw_frame.f_code.co_filename)
        )
Ejemplo n.º 22
0
def _extract_stack(stack, max_depth):
    """Create a list of Frame from a list of FrameSummary.

    :param stack: A list of FrameSummary.
    """
    result = []
    for raw_frame, line_no in stack:
        _maybe_add_boto_operation_name(raw_frame, result)
        co = raw_frame.f_code
        result.append(
            Frame(name=co.co_name, class_name=_extract_class(raw_frame.f_locals), line_no=line_no,
                  file_path=co.co_filename)
        )
    if len(result) < max_depth:
        last_frame, last_frame_line_no = stack[-1]
        _maybe_append_synthetic_frame(result, last_frame, last_frame_line_no)
    return result[:max_depth]
Ejemplo n.º 23
0
def _extract_stack(stack, max_depth):
    """Create a list of Frame from a list of FrameSummary.

    :param stack: A list of FrameSummary.
    """
    result = []
    for raw_frame, line_no in stack:
        co = raw_frame.f_code
        result.append(
            Frame(name=co.co_name,
                  class_name=_extract_class(raw_frame.f_locals),
                  line_no=line_no,
                  file_path=co.co_filename))
    if len(stack) < max_depth:
        last_frame, last_frame_line_no = stack[-1]
        _maybe_append_time_sleep(result, last_frame, last_frame_line_no)
    return result
Ejemplo n.º 24
0
    def test_when_file_path_does_not_exist_it_returns_a_new_child_node_with_None_file_path(self):
        new_child_node = self.subject.update_current_node_and_get_child(
            Frame("new_child_frame", file_path=None))

        assert (new_child_node.file_path is None)
Ejemplo n.º 25
0
"""
This module handles all interactions with python sys and traceback library for sampling.
"""
import linecache
import threading
import traceback
import re
from codeguru_profiler_agent.model.frame import Frame

BOTO_CLIENT_PATH = re.compile("[/\\\\]botocore[/\\\\]client.py$")
TRUNCATED_FRAME = Frame(name="<Truncated>")

TIME_SLEEP_FRAME = Frame(name="<Sleep>")
LXML_SCHEMA_FRAME = Frame(name="lxml.etree:XMLSchema:__init__")
QUEUE_BLOCKING_GET_FRAME = Frame(name="<queue.get>")


def get_stacks(threads_to_sample, excluded_threads, max_depth):
    """
    Attempts to extract the call stacks for the threads listed in threads_to_sample.

    :param threads_to_sample: list of threads to be sampled, expected in the same format as sys._current_frames().items()
    :param excluded_threads: set of thread names to be excluded from sampling
    :param max_depth: the maximum number of frames a stack can have
    :returns: a list of lists of call stacks of all chosen threads; any thread stacks deeper than max_depth will be truncated and the TRUNCATED_FRAME_NAME will be added as a replacement of the **TOPMOST** frames of the stack
    """
    stacks = []
    if max_depth < 0:
        max_depth = 0
    for thread_id, end_frame in threads_to_sample:
        if _is_excluded(thread_id, excluded_threads):
Ejemplo n.º 26
0
    def test_when_line_no_does_not_exist_it_returns_a_new_child_node_with_None_line_no(self):
        new_child_node = self.subject.update_current_node_and_get_child(
            Frame("new_child_frame", line_no=None))

        assert (new_child_node.start_line is None)
        assert (new_child_node.end_line is None)
Ejemplo n.º 27
0
    def test_when_child_node_with_frame_already_existed_it_does_not_add_a_new_one(self):
        self.subject.update_current_node_and_get_child(Frame("new_child_frame"))

        self.subject.update_current_node_and_get_child(Frame("new_child_frame"))

        assert (len(self.subject.children) == 1)
 def test_add_stack_set_profile_end(self):
     self.subject.add(
         Sample(stacks=[[Frame("frame1")]],
                attempted_sample_threads_count=12))
     test_end_time = self.subject.start + 1000
     assert self.subject.end == test_end_time
class TestAdd(TestProfile):
    @before
    def before(self):
        super().before()
        self.turn_clock(1)

    @pytest.mark.parametrize(
        "stacks, expected",
        [
            ([[
                Frame("method_one"),
                Frame("method_two"),
                Frame("method_three")
            ]], {
                "count": 0,
                "children": {
                    "method_one": {
                        "count": 0,
                        "children": {
                            "method_two": {
                                "count": 0,
                                "children": {
                                    "method_three": {
                                        "count": 1,
                                        "children": {}
                                    }
                                }
                            }
                        }
                    }
                }
            }),
            ([[
                Frame("method_one"),
                Frame("method_two"),
                Frame("method_three"),
                Frame("method_five")
            ],
              [
                  Frame("method_one"),
                  Frame("method_two"),
                  Frame("method_four"),
                  Frame("method_five")
              ],
              [
                  Frame("method_one"),
                  Frame("method_two"),
                  Frame("method_three"),
                  Frame("method_six")
              ],
              [
                  Frame("method_one"),
                  Frame("method_seven"),
                  Frame("method_three")
              ]], {
                  "count": 0,
                  "children": {
                      "method_one": {
                          "count": 0,
                          "children": {
                              "method_two": {
                                  "count": 0,
                                  "children": {
                                      "method_three": {
                                          "count": 0,
                                          "children": {
                                              "method_five": {
                                                  "count": 1,
                                                  "children": {}
                                              },
                                              "method_six": {
                                                  "count": 1,
                                                  "children": {}
                                              }
                                          }
                                      },
                                      "method_four": {
                                          "count": 0,
                                          "children": {
                                              "method_five": {
                                                  "count": 1,
                                                  "children": {}
                                              }
                                          }
                                      }
                                  }
                              },
                              "method_seven": {
                                  "count": 0,
                                  "children": {
                                      "method_three": {
                                          "count": 1,
                                          "children": {}
                                      }
                                  }
                              }
                          }
                      }
                  }
              }),
            ([[
                Frame("method_one"),
                Frame("method_two"),
                Frame("method_three"),
                Frame("method_four")
            ],
              [
                  Frame("method_one"),
                  Frame("method_two"),
                  Frame("method_three"),
                  Frame("method_four")
              ]], {
                  "count": 0,
                  "children": {
                      "method_one": {
                          "count": 0,
                          "children": {
                              "method_two": {
                                  "count": 0,
                                  "children": {
                                      "method_three": {
                                          "count": 0,
                                          "children": {
                                              "method_four": {
                                                  "count": 2,
                                                  "children": {}
                                              }
                                          }
                                      }
                                  }
                              }
                          }
                      }
                  }
              }),
            ([[
                Frame("method_one"),
                Frame("method_two"),
                Frame("method_three")
            ], [Frame("method_one"), Frame("method_two")]], {
                "count": 0,
                "children": {
                    "method_one": {
                        "count": 0,
                        "children": {
                            "method_two": {
                                "count": 1,
                                "children": {
                                    "method_three": {
                                        "count": 1,
                                        "children": {}
                                    }
                                }
                            }
                        }
                    }
                }
            }),
            ([[
                Frame("method_one", file_path="path/file1.py"),
                Frame("method_two", file_path="path/file2.py"),
                Frame("method_three", file_path="path/file3.py")
            ],
              [
                  Frame("method_one", file_path="path/file1.py"),
                  Frame("method_two", file_path="path/file2.py")
              ]], {
                  "count": 0,
                  "children": {
                      "method_one": {
                          "count": 0,
                          "children": {
                              "method_two": {
                                  "count": 1,
                                  "children": {
                                      "method_three": {
                                          "count": 1,
                                          "children": {},
                                          "file": "path/file3.py"
                                      }
                                  },
                                  "file": "path/file2.py"
                              }
                          },
                          "file": "path/file1.py"
                      }
                  }
              }),
            # The following test case is for testing that line_no is correctly written to the profile; it covers
            # when line_no points to a specific line or to a range of lines represented in a list
            ([[
                Frame("method_one", file_path="path/file1.py", line_no=1),
                Frame("method_two", file_path="path/file2.py", line_no=10),
                Frame("method_three", file_path="path/file3.py", line_no=100)
            ],
              [
                  Frame("method_one", file_path="path/file1.py", line_no=1),
                  Frame("method_two", file_path="path/file2.py", line_no=20),
                  Frame("method_three", file_path="path/file3.py", line_no=90)
              ]], {
                  "count": 0,
                  "children": {
                      "method_one": {
                          "count": 0,
                          "children": {
                              "method_two": {
                                  "count": 0,
                                  "children": {
                                      "method_three": {
                                          "count": 2,
                                          "children": {},
                                          "file": "path/file3.py",
                                          "line": [90, 100]
                                      }
                                  },
                                  "file": "path/file2.py",
                                  "line": [10, 20]
                              }
                          },
                          "file": "path/file1.py",
                          "line": [1]
                      }
                  }
              }),
            # The following test case is for testing that class_name is correctly written to the profile; it covers
            # the cases when frame name/ file_path are the same when the class_name is different; frame_name/ file_path
            # are different when the class_name is the same
            ([[
                Frame("method_one",
                      file_path="path/file1.py",
                      class_name="ClassA"),
                Frame("method_two",
                      file_path="path/file2.py",
                      class_name="ClassB")
            ],
              [
                  Frame("method_one",
                        file_path="path/file1.py",
                        class_name="ClassA"),
                  Frame("method_two",
                        file_path="path/file2.py",
                        class_name="AnotherClassB")
              ],
              [
                  Frame("another_method_one",
                        file_path="path/file1.py",
                        class_name="ClassA")
              ],
              [
                  Frame("method_one",
                        file_path="path/another_file1.py",
                        class_name="ClassA")
              ]], {
                  "count": 0,
                  "children": {
                      "method_one": {
                          "count": 0,
                          "children": {
                              "method_two": {
                                  "count": 1,
                                  "children": {},
                                  "file": "path/file2.py",
                                  "class_name": "ClassB"
                              },
                              "method_two": {
                                  "count": 1,
                                  "children": {},
                                  "file": "path/file2.py",
                                  "class_name": "AnotherClassB"
                              }
                          },
                          "file": "path/file1.py",
                          "class_name": "ClassA"
                      },
                      "another_method_one": {
                          "count": 1,
                          "children": {},
                          "file": "path/file1.py",
                          "class_name": "ClassA"
                      },
                      "method_one": {
                          "count": 1,
                          "children": {},
                          "file": "path/another_file1.py",
                          "class_name": "ClassA"
                      }
                  }
              })
        ])
    def test_add_stack(self, stacks, expected):
        sample = Sample(stacks=stacks)

        self.subject.add(sample)

        assert (_convert_profile_into_dict(self.subject) == expected)

    def test_add_stack_set_profile_end(self):
        self.subject.add(
            Sample(stacks=[[Frame("frame1")]],
                   attempted_sample_threads_count=12))
        test_end_time = self.subject.start + 1000
        assert self.subject.end == test_end_time

    def test_it_keeps_the_total_sum_of_the_attempted_sample_threads_count_values(
            self):
        sample1 = Sample(stacks=[[Frame("frame1")]],
                         attempted_sample_threads_count=12)
        sample2 = Sample(stacks=[[Frame("frame1")]],
                         attempted_sample_threads_count=34)

        self.subject.add(sample1)
        self.subject.add(sample2)

        assert (self.subject.total_attempted_sample_threads_count == (12 + 34))

    def test_it_keeps_the_total_sum_of_the_seen_threads_count_values(self):
        sample1 = Sample(stacks=[[Frame("frame1")]], seen_threads_count=56)
        sample2 = Sample(stacks=[[Frame("frame1")]], seen_threads_count=78)

        self.subject.add(sample1)
        self.subject.add(sample2)

        assert (self.subject.total_seen_threads_count == (56 + 78))
Ejemplo n.º 30
0
    def test_when_child_node_with_frame_already_existed_it_returns_the_existing_child_node(
            self):
        new_child_node = self.subject.update_current_node_and_get_child(Frame("new_child_frame"))

        assert (self.subject.update_current_node_and_get_child(Frame("new_child_frame")) is new_child_node)