コード例 #1
0
    def test_class_init(self):
        """Watch a class's ``__init__`` method."""
        with wrapping.watch_namespace(
                dependency_analyzer._FakeModule.__init__,  # pylint: disable=protected-access
        ) as container:
            dependency_analyzer._FakeModule("text")  # pylint: disable=protected-access

        self.assertEqual([(("text", ), dict(), None)],
                         [record.get_all() for record in container])
コード例 #2
0
    def test_instance_method_003(self):
        """Watch an instance's method."""
        item = dependency_analyzer._FakeModule(  # pylint: disable=protected-access
            "text")

        with wrapping.watch_namespace(item.get_path) as container:
            item.get_path()

        self.assertEqual([(tuple(), dict(), "text")],
                         [record.get_all() for record in container])
コード例 #3
0
    def test_instance_dunder(self):
        """Watch an instance's ``__repr__`` dunder (double-underscore) method."""

        with wrapping.watch_namespace(dependency_analyzer._FakeModule.__repr__  # pylint: disable=protected-access
                                      ) as container:
            item = dependency_analyzer._FakeModule(  # pylint: disable=protected-access
                "text")
            repr(item)

        self.assertEqual(
            [(tuple(), dict(), "_FakeModule('text')")],
            [record.get_all() for record in container],
        )