# Path: pympler/summary.py
# def _init_representations():
# def summarize(objects):
# def get_diff(left, right):
# def format_(rows, limit=15, sort='size', order='descending'):
# def _format_table(rows, header=True):
# def print_(rows, limit=15, sort='size', order='descending'):
# def _repr(o, verbosity=1):
# def _traverse(summary, function, *args):
# def _subtract(summary, o):
# def _sweep(summary):
# 
# Path: pympler/muppy.py
# def ignore_object(obj: Any) -> bool:
# def get_objects(remove_dups: bool = True, include_frames: bool = False
#                 ) -> List[Any]:
# def get_size(objects: List[Any]) -> int:
# def get_diff(left: List[Any], right: List[Any]) -> Dict[str, List[Any]]:
#     def partition(objects: List[Any]) -> Dict[type, List[Any]]:
#     def get_not_included(foo: List[Any], bar: Dict[type, List[Any]]
#                          ) -> List[Any]:
# def sort(objects: List[Any]) -> List[Any]:
# def filter(objects: List[Any], Type: Optional[type] = None, min: int = -1,
#            max: int = -1) -> List[Any]:
# def get_referents(object: Any, level: int = 1) -> List[Any]:
# def _get_usage(function: Callable, *args: Any) -> Optional[List]:
#     def _get_summaries(function: Callable, *args: Any) -> Tuple:
#     def _get_usage(function: Callable, *args: Any) -> List:
#     def noop() -> None:
# def _is_containerobject(o: Any) -> bool:
# def _remove_duplicates(objects: List[Any]) -> List[Any]:
# def print_summary() -> None:


import doctest
import sys
import unittest
from io import StringIO
from sys import getsizeof
from pympler import summary, muppy

    def test_summary_diff(self):
        """Test summary diff. """
        left = [[str(str), 3, 3*getsizeof('a')],\
                [str(int), 2, 2*getsizeof(1)],\
                [str(list), 1, getsizeof([])],\
                [str(dict), 1, getsizeof({})]]
        right = [[str(str), 2, 2*getsizeof('a')],\
                 [str(int), 3, 3*getsizeof(1)],\
                 [str(list), 1, getsizeof([1,2,3])],\
                 [str(dict), 1, getsizeof({})],
                 [str(tuple), 1, getsizeof((1,2))]]

        expected = [[str(str), -1, -1*getsizeof('a')],\
                    [str(int), 1, +1*getsizeof(1)],\
                    [str(list), 0, getsizeof([1,2,3]) - getsizeof([])],\
                    [str(dict), 0, 0],
                    [str(tuple), 1, getsizeof((1,2))]]
        res = summary.get_diff(left, right)
        for row_e in res:
            self.assertTrue(row_e in expected)


    def test_print_diff(self):
        """Test summary can be printed."""
        try:
            self._stdout = sys.stdout
            stream = StringIO()
            sys.stdout = stream
            sum1 = summary.summarize(muppy.get_objects())

# Path: pympler/summary.py
# def _init_representations():
# def summarize(objects):
# def get_diff(left, right):
# def format_(rows, limit=15, sort='size', order='descending'):
# def _format_table(rows, header=True):
# def print_(rows, limit=15, sort='size', order='descending'):
# def _repr(o, verbosity=1):
# def _traverse(summary, function, *args):
# def _subtract(summary, o):
# def _sweep(summary):
# 
# Path: pympler/muppy.py
# def ignore_object(obj: Any) -> bool:
# def get_objects(remove_dups: bool = True, include_frames: bool = False
#                 ) -> List[Any]:
# def get_size(objects: List[Any]) -> int:
# def get_diff(left: List[Any], right: List[Any]) -> Dict[str, List[Any]]:
#     def partition(objects: List[Any]) -> Dict[type, List[Any]]:
#     def get_not_included(foo: List[Any], bar: Dict[type, List[Any]]
#                          ) -> List[Any]:
# def sort(objects: List[Any]) -> List[Any]:
# def filter(objects: List[Any], Type: Optional[type] = None, min: int = -1,
#            max: int = -1) -> List[Any]:
# def get_referents(object: Any, level: int = 1) -> List[Any]:
# def _get_usage(function: Callable, *args: Any) -> Optional[List]:
#     def _get_summaries(function: Callable, *args: Any) -> Tuple:
#     def _get_usage(function: Callable, *args: Any) -> List:
#     def noop() -> None:
# def _is_containerobject(o: Any) -> bool:
# def _remove_duplicates(objects: List[Any]) -> List[Any]:
# def print_summary() -> None:


# Path: test/muppy/test_summary.py
import doctest
import sys
import unittest
from io import StringIO
from sys import getsizeof
from pympler import summary, muppy


    def test_summary_diff(self):
        """Test summary diff. """
        left = [[str(str), 3, 3*getsizeof('a')],\
                [str(int), 2, 2*getsizeof(1)],\
                [str(list), 1, getsizeof([])],\
                [str(dict), 1, getsizeof({})]]
        right = [[str(str), 2, 2*getsizeof('a')],\
                 [str(int), 3, 3*getsizeof(1)],\
                 [str(list), 1, getsizeof([1,2,3])],\
                 [str(dict), 1, getsizeof({})],
                 [str(tuple), 1, getsizeof((1,2))]]

        expected = [[str(str), -1, -1*getsizeof('a')],\
                    [str(int), 1, +1*getsizeof(1)],\
                    [str(list), 0, getsizeof([1,2,3]) - getsizeof([])],\
                    [str(dict), 0, 0],
                    [str(tuple), 1, getsizeof((1,2))]]
        res = summary.get_diff(left, right)
        for row_e in res:
            self.assertTrue(row_e in expected)


    def test_print_diff(self):
        """Test summary can be printed."""
        try:
            self._stdout = sys.stdout
            stream = StringIO()
            sys.stdout = stream
            sum1 = summary.summarize(muppy.get_objects())

            sum2 = summary.summarize(muppy.get_objects())