# Path: px/px_file.py
# class PxFileBuilder:
# class PxFile(object):
#     def __init__(self):
#     def build(self):
#     def __repr__(self):
#     def __init__(self, pid, filetype):
#     def __repr__(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def __hash__(self):
#     def __str__(self):
#     def _resolve_name(self):
#     def device_number(self):
#     def fifo_id(self):
#     def get_endpoints(self):
# def resolve_endpoint(endpoint):
# def call_lsof():
# def lsof_to_files(lsof):
# def get_all():
# 
# Path: px/px_ipc_map.py
#     T = TypeVar("T")
#     S = TypeVar("S")
# FILE_TYPES = ["PIPE", "FIFO", "unix", "IPv4", "IPv6"]
# class IpcMap(object):
# class PeerProcess(object):
#     def __init__(
#         self,
#         process,  # type: px_process.PxProcess
#         files,  # type: Iterable[px_file.PxFile]
#         processes,  # type: Iterable[px_process.PxProcess]
#         is_root,  # type: bool
#     ):
#     def _create_fds(self, is_root):
#     def _create_mapping(self):
#     def _create_indices(self):
#     def _get_other_end_pids(self, file):
#     def add_ipc_entry(self, process, file):
#     def keys(self):
#     def __getitem__(self, process):
#     def __init__(self, name=None, pid=None):
#     def __repr__(self):
#     def __hash__(self):
#     def __str__(self):
# def create_pid2process(processes):
# def add_arraymapping(mapping, key, value):


import os.path
from px import px_file
from px import px_ipc_map
from . import testutils
        # Set up stdin as an unconnected pipe. The pipe is a real-world OS X one.
        testutils.create_file("PIPE", "", "0x3922f6866312cb55", 1234, fd=0),
    ]

    ipc_map = testutils.create_ipc_map(1234, files, is_root=True)
    assert ipc_map.fds[0] == "[PIPE] <not connected> (0x3922f6866312cb55)"


def test_ipc_pipe_osx():
    # These pipes are real-world OS X ones
    f1 = testutils.create_file(
        "PIPE", "->0x3922f6866312c495", "0x3922f6866312cb55", 2222
    )
    assert f1.fifo_id() == "->0x3922f6866312c495"

    f2 = testutils.create_file(
        "PIPE", "->0x3922f6866312cb55", "0x3922f6866312c495", 1001
    )
    assert f2.fifo_id() == "->0x3922f6866312cb55"

    files = [f1, f2]

    ipc_map = testutils.create_ipc_map(2222, files)
    assert 1001 in ipc_map._get_other_end_pids(f1)
    assert 2222 in ipc_map._get_other_end_pids(f2)
    assert len(list(ipc_map.keys())) == 1


def test_peer_process_str():
    assert str(px_ipc_map.PeerProcess(pid=45)) == "PID 45"

# Path: px/px_file.py
# class PxFileBuilder:
# class PxFile(object):
#     def __init__(self):
#     def build(self):
#     def __repr__(self):
#     def __init__(self, pid, filetype):
#     def __repr__(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def __hash__(self):
#     def __str__(self):
#     def _resolve_name(self):
#     def device_number(self):
#     def fifo_id(self):
#     def get_endpoints(self):
# def resolve_endpoint(endpoint):
# def call_lsof():
# def lsof_to_files(lsof):
# def get_all():
# 
# Path: px/px_ipc_map.py
#     T = TypeVar("T")
#     S = TypeVar("S")
# FILE_TYPES = ["PIPE", "FIFO", "unix", "IPv4", "IPv6"]
# class IpcMap(object):
# class PeerProcess(object):
#     def __init__(
#         self,
#         process,  # type: px_process.PxProcess
#         files,  # type: Iterable[px_file.PxFile]
#         processes,  # type: Iterable[px_process.PxProcess]
#         is_root,  # type: bool
#     ):
#     def _create_fds(self, is_root):
#     def _create_mapping(self):
#     def _create_indices(self):
#     def _get_other_end_pids(self, file):
#     def add_ipc_entry(self, process, file):
#     def keys(self):
#     def __getitem__(self, process):
#     def __init__(self, name=None, pid=None):
#     def __repr__(self):
#     def __hash__(self):
#     def __str__(self):
# def create_pid2process(processes):
# def add_arraymapping(mapping, key, value):


# Path: tests/px_ipc_map_test.py
import os.path
from px import px_file
from px import px_ipc_map
from . import testutils

        # Set up stdin as an unconnected pipe. The pipe is a real-world OS X one.
        testutils.create_file("PIPE", "", "0x3922f6866312cb55", 1234, fd=0),
    ]

    ipc_map = testutils.create_ipc_map(1234, files, is_root=True)
    assert ipc_map.fds[0] == "[PIPE] <not connected> (0x3922f6866312cb55)"


def test_ipc_pipe_osx():
    # These pipes are real-world OS X ones
    f1 = testutils.create_file(
        "PIPE", "->0x3922f6866312c495", "0x3922f6866312cb55", 2222
    )
    assert f1.fifo_id() == "->0x3922f6866312c495"

    f2 = testutils.create_file(
        "PIPE", "->0x3922f6866312cb55", "0x3922f6866312c495", 1001
    )
    assert f2.fifo_id() == "->0x3922f6866312cb55"

    files = [f1, f2]

    ipc_map = testutils.create_ipc_map(2222, files)
    assert 1001 in ipc_map._get_other_end_pids(f1)
    assert 2222 in ipc_map._get_other_end_pids(f2)
    assert len(list(ipc_map.keys())) == 1


def test_peer_process_str():
    assert str(px_ipc_map.PeerProcess(pid=45)) == "PID 45"

    assert str(px_ipc_map.PeerProcess(name="Johan")) == "Johan"