import inspect

from pyinstrument.low_level import stat_profile as stat_profile_c
from pyinstrument.low_level import stat_profile_python


class AClass:
    def get_frame_identifier_for_a_method(self, getter_function):
        frame = inspect.currentframe()
        assert frame
        return getter_function(frame)

    def get_frame_identifier_with_cell_variable(self, getter_function):
        frame = inspect.currentframe()
        assert frame

        def an_inner_function():
            # reference self to make it a cell variable
            if self:
                pass

        return getter_function(frame)

    @classmethod
    def get_frame_identifier_for_a_class_method(cls, getter_function):
        frame = inspect.currentframe()
        assert frame
        return getter_function(frame)


def test_frame_identifier():
    frame = inspect.currentframe()

    assert frame
    assert stat_profile_c.get_frame_identifier(frame) == stat_profile_python.get_frame_identifier(
        frame
    )


def test_frame_identifiers():
    instance = AClass()

    test_functions = [
        instance.get_frame_identifier_for_a_method,
        AClass.get_frame_identifier_for_a_class_method,
        instance.get_frame_identifier_with_cell_variable,
    ]

    for test_function in test_functions:
        assert test_function(stat_profile_c.get_frame_identifier) == test_function(
            stat_profile_python.get_frame_identifier
        )

import inspect

from pyinstrument.low_level import stat_profile as stat_profile_c
from pyinstrument.low_level import stat_profile_python


class AClass:
    def get_frame_identfier_for_a_method(self, getter_function):
        frame = inspect.currentframe()
        assert frame
        return getter_function(frame)

    @classmethod
    def get_frame_identfier_for_a_class_method(cls, getter_function):
        frame = inspect.currentframe()
        assert frame
        return getter_function(frame)


def test_frame_identifier():
    frame = inspect.currentframe()

    assert frame
    assert stat_profile_c.get_frame_identifier(frame) == stat_profile_python.get_frame_identifier(
        frame
    )


def test_frame_identifier_for_method():
    instance = AClass()
    assert instance.get_frame_identfier_for_a_method(
        stat_profile_c.get_frame_identifier
    ) == instance.get_frame_identfier_for_a_method(stat_profile_python.get_frame_identifier)

--- 
+++ 
@@ -5,13 +5,24 @@
 
 
 class AClass:
-    def get_frame_identfier_for_a_method(self, getter_function):
+    def get_frame_identifier_for_a_method(self, getter_function):
         frame = inspect.currentframe()
         assert frame
         return getter_function(frame)
 
+    def get_frame_identifier_with_cell_variable(self, getter_function):
+        frame = inspect.currentframe()
+        assert frame
+
+        def an_inner_function():
+            # reference self to make it a cell variable
+            if self:
+                pass
+
+        return getter_function(frame)
+
     @classmethod
-    def get_frame_identfier_for_a_class_method(cls, getter_function):
+    def get_frame_identifier_for_a_class_method(cls, getter_function):
         frame = inspect.currentframe()
         assert frame
         return getter_function(frame)
@@ -26,8 +37,16 @@
     )
 
 
-def test_frame_identifier_for_method():
+def test_frame_identifiers():
     instance = AClass()
-    assert instance.get_frame_identfier_for_a_method(
-        stat_profile_c.get_frame_identifier
-    ) == instance.get_frame_identfier_for_a_method(stat_profile_python.get_frame_identifier)
+
+    test_functions = [
+        instance.get_frame_identifier_for_a_method,
+        AClass.get_frame_identifier_for_a_class_method,
+        instance.get_frame_identifier_with_cell_variable,
+    ]
+
+    for test_function in test_functions:
+        assert test_function(stat_profile_c.get_frame_identifier) == test_function(
+            stat_profile_python.get_frame_identifier
+        )
Add test for a cell variable
