# Path: tests/utils.py
# @contextmanager
# def temporary_file(content=None, mode=None, binary=False):
#     tmpf, tmpfname = tempfile.mkstemp()
#     os.close(tmpf)
# 
#     if mode is None:
#         if content is None:
#             mode = "rb"
#         else:
#             mode = "wb"
# 
#     tmpf = open(tmpfname, mode)
#     if content is not None:
#         if hasattr(content, "encode") and not binary:
#             tmpf.write(dedent(content).encode("utf8"))
#         else:
#             tmpf.write(content)
# 
#     tmpf.close()
#     yield tmpfname
#     try:
#         os.unlink(tmpfname)
#     except Exception:
#         # ignore exceptions; it happens sometimes on Windows in the CI environment
#         # that it cannot remove the temporary file because another process (?) is
#         # using it...
#         pass


import unittest
        import gc
from igraph import Graph
from .utils import temporary_file
        from time import time

    def testLargestCliques(self):
        self.assertEqual(
            sorted(map(sorted, self.g.largest_cliques())), [[1, 2, 3, 4], [1, 2, 4, 5]]
        )

    def testMaximalCliques(self):
        self.assertEqual(
            sorted(map(sorted, self.g.maximal_cliques())),
            [[0, 3, 4], [0, 4, 5], [1, 2, 3, 4], [1, 2, 4, 5]],
        )
        self.assertEqual(
            sorted(map(sorted, self.g.maximal_cliques(min=4))),
            [[1, 2, 3, 4], [1, 2, 4, 5]],
        )
        self.assertEqual(
            sorted(map(sorted, self.g.maximal_cliques(max=3))), [[0, 3, 4], [0, 4, 5]]
        )

    def testMaximalCliquesFile(self):
        def read_cliques(fname):
            with open(fname) as fp:
                return sorted(sorted(int(item) for item in line.split()) for line in fp)

        with temporary_file() as fname:
            self.g.maximal_cliques(file=fname)
            self.assertEqual(
                [[0, 3, 4], [0, 4, 5], [1, 2, 3, 4], [1, 2, 4, 5]], read_cliques(fname)
            )


# Path: tests/utils.py
# @contextmanager
# def temporary_file(content=None, mode=None, binary=False):
#     tmpf, tmpfname = tempfile.mkstemp()
#     os.close(tmpf)
# 
#     if mode is None:
#         if content is None:
#             mode = "rb"
#         else:
#             mode = "wb"
# 
#     tmpf = open(tmpfname, mode)
#     if content is not None:
#         if hasattr(content, "encode") and not binary:
#             tmpf.write(dedent(content).encode("utf8"))
#         else:
#             tmpf.write(content)
# 
#     tmpf.close()
#     yield tmpfname
#     try:
#         os.unlink(tmpfname)
#     except Exception:
#         # ignore exceptions; it happens sometimes on Windows in the CI environment
#         # that it cannot remove the temporary file because another process (?) is
#         # using it...
#         pass


# Path: tests/test_cliques.py
import unittest
        import gc
from igraph import Graph
from .utils import temporary_file
        from time import time


    def testLargestCliques(self):
        self.assertEqual(
            sorted(map(sorted, self.g.largest_cliques())), [[1, 2, 3, 4], [1, 2, 4, 5]]
        )

    def testMaximalCliques(self):
        self.assertEqual(
            sorted(map(sorted, self.g.maximal_cliques())),
            [[0, 3, 4], [0, 4, 5], [1, 2, 3, 4], [1, 2, 4, 5]],
        )
        self.assertEqual(
            sorted(map(sorted, self.g.maximal_cliques(min=4))),
            [[1, 2, 3, 4], [1, 2, 4, 5]],
        )
        self.assertEqual(
            sorted(map(sorted, self.g.maximal_cliques(max=3))), [[0, 3, 4], [0, 4, 5]]
        )

    def testMaximalCliquesFile(self):
        def read_cliques(fname):
            with open(fname) as fp:
                return sorted(sorted(int(item) for item in line.split()) for line in fp)

        with temporary_file() as fname:
            self.g.maximal_cliques(file=fname)
            self.assertEqual(
                [[0, 3, 4], [0, 4, 5], [1, 2, 3, 4], [1, 2, 4, 5]], read_cliques(fname)
            )


        with temporary_file() as fname: