Skip to content

MocketSocket support for context manager #139

@fvigo

Description

@fvigo

Hi,

MocketSocket doesn't seem to support context manager, so the construct:

with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
    s.connect((target.host, target.port, 0, 0))
    s.sendall(something)
    data = s.recv(4096)

throws an AttributeError:

Traceback (most recent call last):
  File "/home/scanner/scanner.py", line 32, in scan
    with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
AttributeError: __enter__

Is it by design? Any way to work around it (besides rewriting the original code that uses with socket.socket )?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions