repo_id stringclasses 409
values | prefix large_stringlengths 34 36.3k | target large_stringlengths 1 498 | assertion_type stringclasses 31
values | difficulty stringclasses 8
values | test_file stringlengths 10 121 | test_function stringlengths 1 104 | test_class stringlengths 0 51 | lineno int32 2 11.3k | commit_idx int32 |
|---|---|---|---|---|---|---|---|---|---|
magic-wormhole/magic-wormhole | from unittest import mock
from .._key import derive_key, derive_phase_key, encrypt_data, decrypt_data
from ..util import bytes_to_hexstr, hexstr_to_bytes
import pytest
def test_encrypt():
k = "ddc543ef8e4629a603d39dd0307a51bb1e7adb9cb259f6b085c91d0842a18679"
key = hexstr_to_bytes(k)
plaintext = hexstr_to_... | 24 + 16 + 16 | assert | complex_expr | src/wormhole/test/test_keys.py | test_encrypt | 63 | null | |
magic-wormhole/magic-wormhole | from unittest import mock
from zope.interface import alsoProvides
from twisted.internet.task import Clock
from twisted.python.failure import Failure
from twisted.internet.interfaces import IProtocolFactory
from twisted.internet.protocol import Protocol, Factory
import pytest
import pytest_twisted
from ...eventual impo... | 2 | assert | numeric_literal | src/wormhole/test/dilate/test_endpoints.py | test_listener_early_succeed | 219 | null | |
magic-wormhole/magic-wormhole | import json
from nacl.secret import SecretBox
from spake2 import SPAKE2_Symmetric
from zope.interface import directlyProvides, implementer
from unittest import mock
from .. import (__version__, _allocator, _boss, _code, _input, _key, _lister,
_mailbox, _nameplate, _order, _receive, _rendezvous, _send... | 4 | assert | numeric_literal | src/wormhole/test/test_machines.py | test_reversed | 310 | null | |
magic-wormhole/magic-wormhole | import typing
import pytest
import pytest_twisted
from zope.interface import implementer
from twisted.internet.task import deferLater
from twisted.internet.protocol import Factory
from twisted.internet.interfaces import IProtocolFactory
from ... import create
from ...errors import LonelyError
from ...eventual import ... | status1) | assert_* | variable | src/wormhole/test/dilate/test_api.py | test_dilation_status | 192 | null | |
magic-wormhole/magic-wormhole | out = out.decode("utf-8") # make sure we get a string
utf8_locales = {}
for locale in out.splitlines():
locale = locale.strip()
if locale.lower().endswith((".utf-8", ".utf8")):
utf8_locales[locale.lower()] = locale
for wanted in ["C.utf8", "C.UTF-8", "en_US.utf8", "en_US.UTF... | 1 | assert | numeric_literal | src/wormhole/test/test_cli.py | test_override | 1,254 | null | |
magic-wormhole/magic-wormhole | from unittest import mock
from zope.interface import alsoProvides
from twisted.internet.interfaces import ITransport
from ..._dilation._noise import NoiseInvalidMessage, NoiseConnection
from ..._dilation.connection import (IFramer, Frame, Prologue,
_Record, Handshake, KCM,
... | [KCM()] | assert | collection | src/wormhole/test/dilate/test_record.py | test_large_frame | 340 | null | |
magic-wormhole/magic-wormhole | from unittest import mock
from zope.interface import alsoProvides
from twisted.internet.interfaces import ITransport
from ..._dilation._noise import NoiseInvalidMessage, NoiseConnection
from ..._dilation.connection import (IFramer, Frame, Prologue,
_Record, Handshake, KCM,
... | [Handshake()] | assert | collection | src/wormhole/test/dilate/test_record.py | test_large_frame | 332 | null | |
magic-wormhole/magic-wormhole | from .. import journal
from .._interfaces import IJournal
def test_immediate():
events = []
j = journal.ImmediateJournal()
assert IJournal.providedBy(j)
with j.process():
j.queue_outbound(events.append, "message1")
assert events == ["message1"]
j.queue_outbound(events.append, "... | ["message1", "message2"] | assert | collection | src/wormhole/test/test_journal.py | test_immediate | 25 | null | |
magic-wormhole/magic-wormhole | import zope.interface
from attr import Attribute
from attr._make import NOTHING
from wormhole.util import provides
import pytest
def simple_attr(name):
return Attribute(
name=name,
default=NOTHING,
validator=None,
repr=True,
cmp=None,
eq=True,
hash=None,
... | repr(v) | assert | func_call | src/wormhole/test/test_util_attrs_zope.py | test_repr | 64 | null | |
magic-wormhole/magic-wormhole | import json
from nacl.secret import SecretBox
from spake2 import SPAKE2_Symmetric
from zope.interface import directlyProvides, implementer
from unittest import mock
from .. import (__version__, _allocator, _boss, _code, _input, _key, _lister,
_mailbox, _nameplate, _order, _receive, _rendezvous, _send... | 0 | assert | numeric_literal | src/wormhole/test/test_machines.py | test_reversed | 307 | null | |
magic-wormhole/magic-wormhole | from itertools import count
from twisted.internet import reactor
from twisted.internet.threads import deferToThread
from unittest import mock
from pytest_twisted import ensureDeferred
from .._rlcompleter import (CodeInputter, _input_code_with_completion,
input_with_completion, warn_readl... | trueish | assert | variable | src/wormhole/test/test_rlcompleter.py | test_wrapper | 27 | null | |
magic-wormhole/magic-wormhole | from unittest import mock
from .._key import derive_key, derive_phase_key, encrypt_data, decrypt_data
from ..util import bytes_to_hexstr, hexstr_to_bytes
import pytest
def test_derive_phase_key():
m = "588ba9eef353778b074413a0140205d90d7479e36e0dd4ee35bb729d26131ef1"
main = hexstr_to_bytes(m)
dk11 = deri... | "88a1dd12182d989ff498022a9656d1e2" \ "806f17328d8bf5d8d0c9753e4381a752" | assert | string_literal | src/wormhole/test/test_keys.py | test_derive_phase_key | 38 | null | |
magic-wormhole/magic-wormhole | from unittest import mock
from zope.interface import alsoProvides
from ..._interfaces import IDilationManager
from ..._dilation.connection import Open, Data, Close
from ..._dilation.inbound import (Inbound, DuplicateOpenError,
DataForMissingSubchannelError,
... | [] | assert | collection | src/wormhole/test/dilate/test_inbound.py | test_open_data_close | 65 | null | |
magic-wormhole/magic-wormhole | from twisted.internet.task import Clock
from twisted.python.failure import Failure
import pytest
import pytest_twisted
from ..eventual import EventualQueue
from ..observer import OneShotObserver, SequenceObserver, EmptyableSet
@pytest_twisted.ensureDeferred()
async def test_set():
eq = EventualQueue(Clock())
... | None | assert | none_literal | src/wormhole/test/test_observer.py | test_set | 162 | null | |
magic-wormhole/magic-wormhole | from ..._dilation.encode import to_be4, from_be4
import pytest
def test_be4():
assert to_be4(0) == b"\x00\x00\x00\x00"
assert to_be4(1) == b"\x00\x00\x00\x01"
assert to_be4(256) == b"\x00\x00\x01\x00"
assert to_be4(257) == b"\x00\x00\x01\x01"
with pytest.raises(ValueError):
to_be4(-1)
w... | TypeError) | pytest.raises | variable | src/wormhole/test/dilate/test_encoding.py | test_be4 | 20 | null | |
magic-wormhole/magic-wormhole | import unicodedata
from unittest import mock
from .. import util
def test_to_bytes():
b = util.to_bytes("abc")
assert isinstance(b, bytes)
assert b == b"abc"
A = unicodedata.lookup("LATIN SMALL LETTER A WITH DIAERESIS")
b = util.to_bytes(A + "bc")
assert isinstance(b, bytes)
assert b ==... | b"\xc3\xa4\x62\x63" | assert | string_literal | src/wormhole/test/test_util.py | test_to_bytes | 15 | null | |
magic-wormhole/magic-wormhole | import gc
from unittest import mock
from zope.interface import alsoProvides
import twisted.logger
from twisted.internet.task import Clock
from twisted.internet.defer import Deferred
from twisted.internet.address import IPv4Address, IPv6Address, HostnameAddress
from twisted.internet.error import ConnectError
import pyte... | p0 | assert | variable | src/wormhole/test/dilate/test_connector.py | test_no_relay | 83 | null | |
magic-wormhole/magic-wormhole | import os
import sys
from unittest import mock
from ..cli.public_relay import RENDEZVOUS_RELAY, TRANSIT_RELAY
from .common import config
def test_send_appid():
cfg = config("--appid", "xyz", "send", "--text", "hi")
assert cfg.appid == | "xyz" | assert | string_literal | src/wormhole/test/test_args.py | test_send_appid | 27 | null | |
magic-wormhole/magic-wormhole | from unittest import mock
from ..._dilation.connection import (parse_record, encode_record,
KCM, Ping, Pong, Open, Data, Close, Ack)
import pytest
def test_encode():
assert encode_record(KCM()) == b"\x00"
assert encode_record(Ping(ping_id=b"ping")) == b"\x01ping"
asser... | b"\x02pong" | assert | string_literal | src/wormhole/test/dilate/test_parse.py | test_encode | 32 | null | |
magic-wormhole/magic-wormhole | import zope.interface
from attr import Attribute
from attr._make import NOTHING
from wormhole.util import provides
import pytest
def simple_attr(name):
return Attribute(
name=name,
default=NOTHING,
validator=None,
repr=True,
cmp=None,
eq=True,
hash=None,
... | TypeError) | pytest.raises | variable | src/wormhole/test/test_util_attrs_zope.py | test_fail | 56 | null | |
magic-wormhole/magic-wormhole | from zope.interface import alsoProvides
from twisted.internet.task import Clock, Cooperator
from twisted.internet.interfaces import IStreamServerEndpoint
from unittest import mock
import pytest
import pytest_twisted
from ...eventual import EventualQueue
from ..._interfaces import ISend, ITerminator, ISubChannel
from .... | "not recognized" | assert | string_literal | src/wormhole/test/dilate/test_manager.py | test_ping_pong | 609 | null | |
magic-wormhole/magic-wormhole | from unittest import mock
from zope.interface import directlyProvides, implementer
from twisted.internet.interfaces import ITransport, IHalfCloseableProtocol, IProtocol
from twisted.internet.error import ConnectionDone
from ..._interfaces import IDilationManager
from ..._dilation.subchannel import (SubChannel,
... | p.mock_calls) | assert_* | complex_expr | src/wormhole/test/dilate/test_subchannel.py | test_subchannel_local_close | 83 | null | |
magic-wormhole/magic-wormhole | from zope.interface import alsoProvides
from twisted.internet.task import Clock, Cooperator
from twisted.internet.interfaces import IStreamServerEndpoint
from unittest import mock
import pytest
import pytest_twisted
from ...eventual import EventualQueue
from ..._interfaces import ISend, ITerminator, ISubChannel
from .... | [mock.call.stop()] | assert | collection | src/wormhole/test/dilate/test_manager.py | test_follower | 550 | null | |
magic-wormhole/magic-wormhole | import typing
import pytest
import pytest_twisted
from zope.interface import implementer
from twisted.internet.task import deferLater
from twisted.internet.protocol import Factory
from twisted.internet.interfaces import IProtocolFactory
from ... import create
from ...errors import LonelyError
from ...eventual import ... | wormhole_status0) | assert_* | variable | src/wormhole/test/dilate/test_api.py | test_dilation_status | 188 | null | |
magic-wormhole/magic-wormhole | from unittest import mock
from .._key import derive_key, derive_phase_key, encrypt_data, decrypt_data
from ..util import bytes_to_hexstr, hexstr_to_bytes
import pytest
def test_encrypt():
k = "ddc543ef8e4629a603d39dd0307a51bb1e7adb9cb259f6b085c91d0842a18679"
key = hexstr_to_bytes(k)
plaintext = hexstr_to_... | 24 | assert | numeric_literal | src/wormhole/test/test_keys.py | test_encrypt | 60 | null | |
magic-wormhole/magic-wormhole | from twisted.internet.defer import Deferred
from twisted.internet.task import Clock
from unittest import mock
from pytest_twisted import ensureDeferred
from ..eventual import EventualQueue
def test_eventually(observe_errors):
c = Clock()
eq = EventualQueue(c)
c1 = mock.Mock()
eq.eventually(c1, "arg1... | None | assert | none_literal | src/wormhole/test/test_eventual.py | test_eventually | 32 | null | |
magic-wormhole/magic-wormhole | from unittest import mock
from ..._dilation.connection import (parse_record, encode_record,
KCM, Ping, Pong, Open, Data, Close, Ack)
import pytest
def test_encode():
assert encode_record(KCM()) == b"\x00"
assert encode_record(Ping(ping_id=b"ping")) == b"\x01ping"
assert... | TypeError) | pytest.raises | variable | src/wormhole/test/dilate/test_parse.py | test_encode | 41 | null | |
magic-wormhole/magic-wormhole | from unittest import mock
from ..._dilation.connection import (parse_record, encode_record,
KCM, Ping, Pong, Open, Data, Close, Ack)
import pytest
def test_parse():
assert parse_record(b"\x00") == KCM()
assert parse_record(b"\x01\x55\x44\x33\x22") == \
... | Close(scid=515, seqnum=258) | assert | func_call | src/wormhole/test/dilate/test_parse.py | test_parse | 17 | null | |
magic-wormhole/magic-wormhole | import io
from twisted.internet import defer
from twisted.internet.error import ConnectError
from unittest import mock
import pytest
import pytest_twisted
from .._interfaces import ITorManager
from ..errors import NoTorError
from ..tor_manager import SocksOnlyTor, get_tor
@pytest_twisted.ensureDeferred
async def te... | [mock.call(reactor)] | assert | collection | src/wormhole/test/test_tor_manager.py | test_connect | 76 | null | |
magic-wormhole/magic-wormhole | import wormhole
from zope.interface import implementer, alsoProvides
from twisted.internet.defer import Deferred, gatherResults
from twisted.internet.protocol import Protocol, Factory
from twisted.internet.interfaces import IProtocolFactory
import pytest
import pytest_twisted
from ..common import poll_until
from ..._... | b"hello p2\n" | assert | string_literal | src/wormhole/test/dilate/test_full.py | test_endpoints | 391 | null | |
magic-wormhole/magic-wormhole | import io
from twisted.internet import defer
from twisted.internet.error import ConnectError
from unittest import mock
import pytest
import pytest_twisted
from .._interfaces import ITorManager
from ..errors import NoTorError
from ..tor_manager import SocksOnlyTor, get_tor
def test_tor():
reactor = object()
... | fake_ep | assert | variable | src/wormhole/test/test_tor_manager.py | test_tor | 168 | null | |
magic-wormhole/magic-wormhole | import unicodedata
from unittest import mock
from .. import util
def test_hexstr_to_bytes():
hexstr = "004591feff"
b = util.hexstr_to_bytes(hexstr)
hexstr = util.bytes_to_hexstr(b)
assert isinstance(b, bytes)
assert b == | b"\x00\x45\x91\xfe\xff" | assert | string_literal | src/wormhole/test/test_util.py | test_hexstr_to_bytes | 28 | null | |
magic-wormhole/magic-wormhole | from .. import journal
from .._interfaces import IJournal
def test_journal():
events = []
j = journal.Journal(lambda: events.append("checkpoint"))
assert (IJournal.providedBy(j))
with j.process():
j.queue_outbound(events.append, "message1")
j.queue_outbound(events.append, "message2")
... | ["checkpoint", "message1", "message2"] | assert | collection | src/wormhole/test/test_journal.py | test_journal | 13 | null | |
magic-wormhole/magic-wormhole | import io
import re
from twisted.internet.defer import gatherResults
from twisted.internet.error import ConnectionRefusedError
from unittest import mock
from pytest_twisted import ensureDeferred
from .. import _rendezvous, wormhole
from ..errors import (KeyFormatError, LonelyError, NoKeyError,
... | "1-abc" | assert | string_literal | src/wormhole/test/test_wormhole.py | test_delegated | 73 | null | |
magic-wormhole/magic-wormhole | import io
from twisted.internet import defer
from twisted.internet.error import ConnectError
from unittest import mock
import pytest
import pytest_twisted
from .._interfaces import ITorManager
from ..errors import NoTorError
from ..tor_manager import SocksOnlyTor, get_tor
@pytest_twisted.ensureDeferred
async def te... | NoTorError) | pytest.raises | variable | src/wormhole/test/test_tor_manager.py | test_no_txtorcon | 22 | null | |
magic-wormhole/magic-wormhole | import errno
import os
import re
import subprocess
from unittest import mock
from .. import ipaddrs
DOTTED_QUAD_RE = re.compile(r"^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$")
MOCK_IPADDR_OUTPUT = """\
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN \n\
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00... | set(expected) | assert | func_call | src/wormhole/test/test_ipaddrs.py | _test_list_mock | 148 | null | |
magic-wormhole/magic-wormhole | from twisted.internet.task import Clock
from twisted.python.failure import Failure
import pytest
import pytest_twisted
from ..eventual import EventualQueue
from ..observer import OneShotObserver, SequenceObserver, EmptyableSet
@pytest_twisted.ensureDeferred()
async def test_error_before_firing():
c = Clock()
... | Exception) | pytest.raises | variable | src/wormhole/test/test_observer.py | test_error_before_firing | 55 | null | |
magic-wormhole/magic-wormhole | from unittest import mock
from zope.interface import alsoProvides
from twisted.internet.task import Clock
from twisted.python.failure import Failure
from twisted.internet.interfaces import IProtocolFactory
from twisted.internet.protocol import Protocol, Factory
import pytest
import pytest_twisted
from ...eventual impo... | [] | assert | collection | src/wormhole/test/dilate/test_endpoints.py | test_listener_early_fail | 249 | null | |
magic-wormhole/magic-wormhole | import re
from unittest import mock
from twisted.internet import reactor
from twisted.internet.task import Cooperator
from twisted.internet.defer import Deferred
from zope.interface import implementer
import pytest
from pytest_twisted import ensureDeferred
from ... import _interfaces
from ...eventual import EventualQ... | self.rx_phase | assert | complex_expr | src/wormhole/test/dilate/test_connect.py | got | MySend | 31 | null |
magic-wormhole/magic-wormhole | from unittest import mock
from zope.interface import directlyProvides, implementer
from twisted.internet.interfaces import ITransport, IHalfCloseableProtocol, IProtocol
from twisted.internet.error import ConnectionDone
from ..._interfaces import IDilationManager
from ..._dilation.subchannel import (SubChannel,
... | "connectionLost" | assert | string_literal | src/wormhole/test/dilate/test_subchannel.py | assert_connectionDone | 99 | null | |
magic-wormhole/magic-wormhole | from zope.interface import alsoProvides
from twisted.internet.task import Clock, Cooperator
from twisted.internet.interfaces import IStreamServerEndpoint
from unittest import mock
import pytest
import pytest_twisted
from ...eventual import EventualQueue
from ..._interfaces import ISend, ITerminator, ISubChannel
from .... | last_hints | assert | variable | src/wormhole/test/dilate/test_manager.py | test_status_hints | 717 | null | |
magic-wormhole/magic-wormhole | from unittest import mock
from zope.interface import alsoProvides
from twisted.internet.interfaces import ITransport
from ..._dilation._noise import NoiseInvalidMessage, NoiseConnection
from ..._dilation.connection import (IFramer, Frame, Prologue,
_Record, Handshake, KCM,
... | [] | assert | collection | src/wormhole/test/dilate/test_record.py | test_good2 | 38 | null | |
magic-wormhole/magic-wormhole | from unittest import mock
from zope.interface import alsoProvides
from twisted.internet.interfaces import ITransport
from ..._dilation.connection import _Framer, Frame, Prologue, Disconnect
import pytest
def make_framer():
t = mock.Mock()
alsoProvides(t, ITransport)
f = _Framer(t, b"outbound_prologue\n", b... | [] | assert | collection | src/wormhole/test/dilate/test_framer.py | test_bad_prologue_length | 17 | null | |
magic-wormhole/magic-wormhole | from unittest import mock
from ..._dilation.connection import (parse_record, encode_record,
KCM, Ping, Pong, Open, Data, Close, Ack)
import pytest
def test_encode():
assert encode_record(KCM()) == b"\x00"
assert encode_record(Ping(ping_id=b"ping")) == b"\x01ping"
assert... | "not a record" | assert | string_literal | src/wormhole/test/dilate/test_parse.py | test_encode | 43 | null | |
magic-wormhole/magic-wormhole | from unittest import mock
from zope.interface import alsoProvides
from twisted.internet.task import Clock
from twisted.internet.interfaces import ITransport
import pytest_twisted
from ...eventual import EventualQueue
from ..._interfaces import IDilationConnector
from ..._dilation.roles import LEADER, FOLLOWER
from ...... | [] | assert | collection | src/wormhole/test/dilate/test_connection.py | test_bad_prologue | 41 | null | |
magic-wormhole/magic-wormhole | import unicodedata
from unittest import mock
from .. import util
def test_dict_to_bytes():
d = {"a": "b"}
b = util.dict_to_bytes(d)
assert isinstance(b, bytes)
assert b == | b'{"a": "b"}' | assert | string_literal | src/wormhole/test/test_util.py | test_dict_to_bytes | 34 | null | |
magic-wormhole/magic-wormhole | from unittest import mock
from .._wordlist import PGPWordList
def test_completions():
wl = PGPWordList()
gc = wl.get_completions
assert gc("ar", 2) == {"armistice-", "article-"}
assert gc("armis", 2) == {"armistice-"}
assert gc("armistice", 2) == {"armistice-"}
lots = gc("armistice-", 2)
a... | {"armistice-baboon-"} | assert | collection | src/wormhole/test/test_wordlist.py | test_completions | 20 | null | |
magic-wormhole/magic-wormhole | import io
import os
from unittest import mock
from ..cli import cmd_ssh
import pytest
OTHERS = ["config", "config~", "known_hosts", "known_hosts~"]
def test_comment_with_spaces():
files = OTHERS + ["id_ed25519.pub", "id_ed25519"]
pubkey_data = "ssh-ed25519 AAAAkeystuff comment with spaces"
pubkey_file =... | "comment with spaces" | assert | string_literal | src/wormhole/test/test_ssh.py | test_comment_with_spaces | 78 | null | |
magic-wormhole/magic-wormhole | import wormhole
from zope.interface import implementer, alsoProvides
from twisted.internet.defer import Deferred, gatherResults
from twisted.internet.protocol import Protocol, Factory
from twisted.internet.interfaces import IProtocolFactory
import pytest
import pytest_twisted
from ..common import poll_until
from ..._... | b"more\n" | assert | string_literal | src/wormhole/test/dilate/test_full.py | test_reconnect | 248 | null | |
magic-wormhole/magic-wormhole | from unittest import mock
from zope.interface import alsoProvides
from twisted.internet.interfaces import ITransport
from ..._dilation.connection import _Framer, Frame, Prologue, Disconnect
import pytest
def make_framer():
t = mock.Mock()
alsoProvides(t, ITransport)
f = _Framer(t, b"outbound_prologue\n", b... | list(f.add_and_parse(b"not")) | assert | func_call | src/wormhole/test/dilate/test_framer.py | test_bad_prologue_newline | 42 | null | |
magic-wormhole/magic-wormhole | from unittest import mock
from .._key import derive_key, derive_phase_key, encrypt_data, decrypt_data
from ..util import bytes_to_hexstr, hexstr_to_bytes
import pytest
def test_encrypt():
k = "ddc543ef8e4629a603d39dd0307a51bb1e7adb9cb259f6b085c91d0842a18679"
key = hexstr_to_bytes(k)
plaintext = hexstr_to_... | 16 | assert | numeric_literal | src/wormhole/test/test_keys.py | test_encrypt | 57 | null | |
magic-wormhole/magic-wormhole | import pytest
from ..._dilation.manager import TrafficTimer
def traffic_timer():
yield TimerFixture()
def test_one_interval(traffic_timer):
"""
No reconnect when only a single interval has passed
"""
traffic_timer.t.got_connection()
traffic_timer.t.interval_elapsed()
# timer must be re-sta... | [0, 1] | assert | collection | src/wormhole/test/dilate/test_traffic_timing.py | test_one_interval | 44 | null | |
magic-wormhole/magic-wormhole | import unicodedata
from unittest import mock
from .. import util
def test_no_statvfs():
# this mock.patch fails on windows, which is sad because windows is
# the one platform that the code under test was supposed to help with
try:
with mock.patch("os.statvfs", side_effect=AttributeError()):
... | None | assert | none_literal | src/wormhole/test/test_util.py | test_no_statvfs | 55 | null | |
magic-wormhole/magic-wormhole | from itertools import count
from twisted.internet import reactor
from twisted.internet.threads import deferToThread
from unittest import mock
from pytest_twisted import ensureDeferred
from .._rlcompleter import (CodeInputter, _input_code_with_completion,
input_with_completion, warn_readl... | ["1", "12"] | assert | collection | src/wormhole/test/test_rlcompleter.py | test_call | 184 | null | |
magic-wormhole/magic-wormhole | from .. import journal
from .._interfaces import IJournal
def test_journal():
events = []
j = journal.Journal(lambda: events.append("checkpoint"))
assert (IJournal.providedBy(j))
with j.process():
j.queue_outbound(events.append, "message1")
j.queue_outbound(events.append, "message2")
... | [] | assert | collection | src/wormhole/test/test_journal.py | test_journal | 12 | null | |
magic-wormhole/magic-wormhole | from .. import journal
from .._interfaces import IJournal
def test_immediate():
events = []
j = journal.ImmediateJournal()
assert IJournal.providedBy(j)
with j.process():
j.queue_outbound(events.append, "message1")
assert events == | ["message1"] | assert | collection | src/wormhole/test/test_journal.py | test_immediate | 22 | null | |
magic-wormhole/magic-wormhole | import unicodedata
from unittest import mock
from .. import util
def test_bytes_to_dict():
b = b'{"a": "b", "c": 2}'
d = util.bytes_to_dict(b)
assert isinstance(d, dict)
assert d == | {"a": "b", "c": 2} | assert | collection | src/wormhole/test/test_util.py | test_bytes_to_dict | 40 | null | |
magic-wormhole/magic-wormhole | import unicodedata
from unittest import mock
from .. import util
def test_bytes_to_hexstr():
b = b"\x00\x45\x91\xfe\xff"
hexstr = util.bytes_to_hexstr(b)
assert isinstance(hexstr, str)
assert hexstr == | "004591feff" | assert | string_literal | src/wormhole/test/test_util.py | test_bytes_to_hexstr | 21 | null | |
magic-wormhole/magic-wormhole | import io
from twisted.internet import defer
from twisted.internet.error import ConnectError
from unittest import mock
import pytest
import pytest_twisted
from .._interfaces import ITorManager
from ..errors import NoTorError
from ..tor_manager import SocksOnlyTor, get_tor
@pytest_twisted.ensureDeferred
async def te... | my_tor | assert | variable | src/wormhole/test/test_tor_manager.py | test_connect | 79 | null | |
magic-wormhole/magic-wormhole | import typing
import pytest
import pytest_twisted
from zope.interface import implementer
from twisted.internet.task import deferLater
from twisted.internet.protocol import Factory
from twisted.internet.interfaces import IProtocolFactory
from ... import create
from ...errors import LonelyError
from ...eventual import ... | generations | assert | variable | src/wormhole/test/dilate/test_api.py | assert_dilation_status_order | 73 | null | |
magic-wormhole/magic-wormhole | from ..._dilation.encode import to_be4, from_be4
import pytest
def test_be4():
assert to_be4(0) == b"\x00\x00\x00\x00"
assert to_be4(1) == b"\x00\x00\x00\x01"
assert to_be4(256) == b"\x00\x00\x01\x00"
assert to_be4(257) == b"\x00\x00\x01\x01"
with pytest.raises(ValueError):
to_be4(-1)
w... | 1 | assert | numeric_literal | src/wormhole/test/dilate/test_encoding.py | test_be4 | 16 | null | |
magic-wormhole/magic-wormhole | import io
from collections import namedtuple
from unittest import mock
from twisted.internet import endpoints, reactor
from .._hints import (endpoint_from_hint_obj, parse_hint_argv, parse_tcp_v1_hint,
describe_hint_obj, parse_hint, encode_hint,
DirectTCPV1Hint, TorTCPV1Hint, ... | "" | assert | string_literal | src/wormhole/test/test_hints.py | test_parse_hint_argv | 114 | null | |
magic-wormhole/magic-wormhole | import io
import re
from twisted.internet.defer import gatherResults
from twisted.internet.error import ConnectionRefusedError
from unittest import mock
from pytest_twisted import ensureDeferred
from .. import _rendezvous, wormhole
from ..errors import (KeyFormatError, LonelyError, NoKeyError,
... | v1 | assert | variable | src/wormhole/test/test_wormhole.py | test_verifier | 600 | null | |
magic-wormhole/magic-wormhole | from wormhole._dilation.manager import _find_shared_versions
def test_versions():
assert _find_shared_versions([],[]) is None
assert _find_shared_versions(["foo"],["foo"]) == | "foo" | assert | string_literal | src/wormhole/test/dilate/test_version.py | test_versions | 6 | null | |
magic-wormhole/magic-wormhole | import gc
from unittest import mock
from zope.interface import alsoProvides
import twisted.logger
from twisted.internet.task import Clock
from twisted.internet.defer import Deferred
from twisted.internet.address import IPv4Address, IPv6Address, HostnameAddress
from twisted.internet.error import ConnectError
import pyte... | [] | assert | collection | src/wormhole/test/dilate/test_connector.py | test_no_relay | 85 | null | |
magic-wormhole/magic-wormhole | from unittest import mock
from .._wordlist import PGPWordList
def test_completions():
wl = PGPWordList()
gc = wl.get_completions
assert gc("ar", 2) == {"armistice-", "article-"}
assert gc("armis", 2) == {"armistice-"}
assert gc("armistice", 2) == {"armistice-"}
lots = gc("armistice-", 2)
a... | {"armistice-baboon"} | assert | collection | src/wormhole/test/test_wordlist.py | test_completions | 19 | null | |
magic-wormhole/magic-wormhole | import io
import os
from unittest import mock
from ..cli import cmd_ssh
import pytest
OTHERS = ["config", "config~", "known_hosts", "known_hosts~"]
def test_find_one():
files = OTHERS + ["id_rsa.pub", "id_rsa"]
pubkey_data = "ssh-rsa AAAAkeystuff email@host\n"
pubkey_file = io.StringIO(pubkey_data)
... | pubkey_data | assert | variable | src/wormhole/test/test_ssh.py | test_find_one | 27 | null | |
magic-wormhole/magic-wormhole | from ..._dilation.encode import to_be4, from_be4
import pytest
def test_be4():
assert to_be4(0) == b"\x00\x00\x00\x00"
assert to_be4(1) == b"\x00\x00\x00\x01"
assert to_be4(256) == b"\x00\x00\x01\x00"
assert to_be4(257) == b"\x00\x00\x01\x01"
with pytest.raises(ValueError):
to_be4(-1)
w... | 0 | assert | numeric_literal | src/wormhole/test/dilate/test_encoding.py | test_be4 | 15 | null | |
magic-wormhole/magic-wormhole | import typing
import pytest
import pytest_twisted
from zope.interface import implementer
from twisted.internet.task import deferLater
from twisted.internet.protocol import Factory
from twisted.internet.interfaces import IProtocolFactory
from ... import create
from ...errors import LonelyError
from ...eventual import ... | peers | assert | variable | src/wormhole/test/dilate/test_api.py | assert_dilation_status_order | 86 | null | |
magic-wormhole/magic-wormhole | import io
from twisted.internet import defer
from twisted.internet.error import ConnectError
from unittest import mock
import pytest
import pytest_twisted
from .._interfaces import ITorManager
from ..errors import NoTorError
from ..tor_manager import SocksOnlyTor, get_tor
@pytest_twisted.ensureDeferred
async def te... | reactor | assert | variable | src/wormhole/test/test_tor_manager.py | test_connect_fails | 105 | null | |
magic-wormhole/magic-wormhole | import io
from binascii import hexlify, unhexlify
from nacl.exceptions import CryptoError
from nacl.secret import SecretBox
from twisted.internet import address, defer, endpoints, error, protocol, task
from twisted.internet.defer import gatherResults
from twisted.test import proto_helpers
from unittest import mock
fr... | p | assert | variable | src/wormhole/test/test_transit.py | test_success_inbound | 460 | null | |
magic-wormhole/magic-wormhole | from zope.interface import alsoProvides
from twisted.internet.task import Clock, Cooperator
from twisted.internet.interfaces import IStreamServerEndpoint
from unittest import mock
import pytest
import pytest_twisted
from ...eventual import EventualQueue
from ..._interfaces import ISend, ITerminator, ISubChannel
from .... | ValueError) | pytest.raises | variable | src/wormhole/test/dilate/test_manager.py | test_mirror | 590 | null | |
magic-wormhole/magic-wormhole | from unittest import mock
from zope.interface import alsoProvides
from twisted.internet.interfaces import ITransport
from ..._dilation._noise import NoiseInvalidMessage, NoiseConnection
from ..._dilation.connection import (IFramer, Frame, Prologue,
_Record, Handshake, KCM,
... | 1 | assert | numeric_literal | src/wormhole/test/dilate/test_record.py | test_large_frame | 374 | null | |
magic-wormhole/magic-wormhole | from itertools import count
from twisted.internet import reactor
from twisted.internet.threads import deferToThread
from unittest import mock
from pytest_twisted import ensureDeferred
from .._rlcompleter import (CodeInputter, _input_code_with_completion,
input_with_completion, warn_readl... | "oops" | assert | string_literal | src/wormhole/test/test_rlcompleter.py | test_wrap_error | 223 | null | |
magic-wormhole/magic-wormhole | import wormhole
from zope.interface import implementer, alsoProvides
from twisted.internet.defer import Deferred, gatherResults
from twisted.internet.protocol import Protocol, Factory
from twisted.internet.interfaces import IProtocolFactory
import pytest
import pytest_twisted
from ..common import poll_until
from ..._... | b"hello\n" | assert | string_literal | src/wormhole/test/dilate/test_full.py | test_single_subprotocol | 89 | null | |
magic-wormhole/magic-wormhole | import io
import os
from unittest import mock
from ..cli import cmd_ssh
import pytest
OTHERS = ["config", "config~", "known_hosts", "known_hosts~"]
def test_bad_hint():
with mock.patch("wormhole.cli.cmd_ssh.exists", return_value=False):
with pytest.raises(cmd_ssh.PubkeyError) as f:
cmd_ssh.f... | "Can't find 'bogus/path'" | assert | string_literal | src/wormhole/test/test_ssh.py | test_bad_hint | 42 | null | |
magic-wormhole/magic-wormhole | import gc
from unittest import mock
from zope.interface import alsoProvides
import twisted.logger
from twisted.internet.task import Clock
from twisted.internet.defer import Deferred
from twisted.internet.address import IPv4Address, IPv6Address, HostnameAddress
from twisted.internet.error import ConnectError
import pyte... | f | assert | variable | src/wormhole/test/dilate/test_connector.py | test_no_relay | 86 | null | |
magic-wormhole/magic-wormhole | from itertools import count
from twisted.internet import reactor
from twisted.internet.threads import deferToThread
from unittest import mock
from pytest_twisted import ensureDeferred
from .._rlcompleter import (CodeInputter, _input_code_with_completion,
input_with_completion, warn_readl... | [mock.call("1")] | assert | collection | src/wormhole/test/test_rlcompleter.py | test_call | 185 | null | |
magic-wormhole/magic-wormhole | import io
from twisted.internet import defer
from twisted.internet.error import ConnectError
from unittest import mock
import pytest
import pytest_twisted
from .._interfaces import ITorManager
from ..errors import NoTorError
from ..tor_manager import SocksOnlyTor, get_tor
@pytest_twisted.ensureDeferred
async def te... | ConnectError) | pytest.raises | variable | src/wormhole/test/test_tor_manager.py | test_connect_custom_control_port_fails | 155 | null | |
magic-wormhole/magic-wormhole | import io
from collections import namedtuple
from unittest import mock
from twisted.internet import endpoints, reactor
from .._hints import (endpoint_from_hint_obj, parse_hint_argv, parse_tcp_v1_hint,
describe_hint_obj, parse_hint, encode_hint,
DirectTCPV1Hint, TorTCPV1Hint, ... | None | assert | none_literal | src/wormhole/test/test_hints.py | test_endpoint_from_hint_obj | 17 | null | |
magic-wormhole/magic-wormhole | import io
import re
from twisted.internet.defer import gatherResults
from twisted.internet.error import ConnectionRefusedError
from unittest import mock
from pytest_twisted import ensureDeferred
from .. import _rendezvous, wormhole
from ..errors import (KeyFormatError, LonelyError, NoKeyError,
... | wel1 | assert | variable | src/wormhole/test/test_wormhole.py | test_welcome | 555 | null | |
magic-wormhole/magic-wormhole | from unittest import mock
from zope.interface import alsoProvides
from twisted.internet.interfaces import ITransport
from ..._dilation._noise import NoiseInvalidMessage, NoiseConnection
from ..._dilation.connection import (IFramer, Frame, Prologue,
_Record, Handshake, KCM,
... | [r1, r2] | assert | collection | src/wormhole/test/dilate/test_record.py | test_good2 | 72 | null | |
magic-wormhole/magic-wormhole | import io
import re
from twisted.internet.defer import gatherResults
from twisted.internet.error import ConnectionRefusedError
from unittest import mock
from pytest_twisted import ensureDeferred
from .. import _rendezvous, wormhole
from ..errors import (KeyFormatError, LonelyError, NoKeyError,
... | code2 | assert | variable | src/wormhole/test/test_wormhole.py | test_wrong_password | 420 | null | |
magic-wormhole/magic-wormhole | import wormhole
from zope.interface import implementer, alsoProvides
from twisted.internet.defer import Deferred, gatherResults
from twisted.internet.protocol import Protocol, Factory
from twisted.internet.interfaces import IProtocolFactory
import pytest
import pytest_twisted
from ..common import poll_until
from ..._... | data4 | assert | variable | src/wormhole/test/dilate/test_full.py | test_double_subprotocol | 147 | null | |
magic-wormhole/magic-wormhole | import io
from collections import namedtuple
from unittest import mock
from twisted.internet import endpoints, reactor
from .._hints import (endpoint_from_hint_obj, parse_hint_argv, parse_tcp_v1_hint,
describe_hint_obj, parse_hint, encode_hint,
DirectTCPV1Hint, TorTCPV1Hint, ... | 1 | assert | numeric_literal | src/wormhole/test/test_hints.py | test_comparable | 48 | null | |
magic-wormhole/magic-wormhole | import io
from twisted.internet import defer
from twisted.internet.error import ConnectError
from unittest import mock
import pytest
import pytest_twisted
from .._interfaces import ITorManager
from ..errors import NoTorError
from ..tor_manager import SocksOnlyTor, get_tor
@pytest_twisted.ensureDeferred
async def te... | ValueError) | pytest.raises | variable | src/wormhole/test/test_tor_manager.py | test_bad_args | 36 | null | |
magic-wormhole/magic-wormhole | from unittest import mock
from zope.interface import alsoProvides
from twisted.internet.interfaces import ITransport
from ..._dilation._noise import NoiseInvalidMessage, NoiseConnection
from ..._dilation.connection import (IFramer, Frame, Prologue,
_Record, Handshake, KCM,
... | Disconnect) | pytest.raises | variable | src/wormhole/test/dilate/test_record.py | test_bad_handshake | 96 | null | |
magic-wormhole/magic-wormhole | import pytest
from ..._dilation.manager import TrafficTimer
def traffic_timer():
yield TimerFixture()
def test_one_interval(traffic_timer):
"""
No reconnect when only a single interval has passed
"""
traffic_timer.t.got_connection()
traffic_timer.t.interval_elapsed()
# timer must be re-sta... | [] | assert | collection | src/wormhole/test/dilate/test_traffic_timing.py | test_one_interval | 45 | null | |
magic-wormhole/magic-wormhole | from unittest import mock
from ..._dilation.connection import (parse_record, encode_record,
KCM, Ping, Pong, Open, Data, Close, Ack)
import pytest
def test_parse():
assert parse_record(b"\x00") == KCM()
assert parse_record(b"\x01\x55\x44\x33\x22") == \
... | Ack(resp_seqnum=259) | assert | func_call | src/wormhole/test/dilate/test_parse.py | test_parse | 19 | null | |
magic-wormhole/magic-wormhole | from twisted.internet.defer import Deferred
from twisted.internet.task import Clock
from unittest import mock
from pytest_twisted import ensureDeferred
from ..eventual import EventualQueue
def test_eventually(observe_errors):
c = Clock()
eq = EventualQueue(c)
c1 = mock.Mock()
eq.eventually(c1, "arg1... | "value" | assert | string_literal | src/wormhole/test/test_eventual.py | test_eventually | 33 | null | |
magic-wormhole/magic-wormhole | import json
from nacl.secret import SecretBox
from spake2 import SPAKE2_Symmetric
from zope.interface import directlyProvides, implementer
from unittest import mock
from .. import (__version__, _allocator, _boss, _code, _input, _key, _lister,
_mailbox, _nameplate, _order, _receive, _rendezvous, _send... | 3 | assert | numeric_literal | src/wormhole/test/test_machines.py | test_good_key | 273 | null | |
magic-wormhole/magic-wormhole | from unittest import mock
from ..._dilation.connection import (parse_record, encode_record,
KCM, Ping, Pong, Open, Data, Close, Ack)
import pytest
def test_parse():
assert parse_record(b"\x00") == KCM()
assert parse_reco | Ping(ping_id=b"\x55\x44\x33\x22") | assert | func_call | src/wormhole/test/dilate/test_parse.py | test_parse | 9 | null | |
magic-wormhole/magic-wormhole | from unittest import mock
from zope.interface import alsoProvides
from twisted.internet.interfaces import ITransport
from ..._dilation.connection import _Framer, Frame, Prologue, Disconnect
import pytest
def make_framer():
t = mock.Mock()
alsoProvides(t, ITransport)
f = _Framer(t, b"outbound_prologue\n", b... | list(f.add_and_parse(b"ok\n")) | assert | func_call | src/wormhole/test/dilate/test_framer.py | test_good_relay | 95 | null | |
magic-wormhole/magic-wormhole | from unittest import mock
from zope.interface import alsoProvides
from twisted.internet.task import Clock
from twisted.internet.interfaces import ITransport
import pytest_twisted
from ...eventual import EventualQueue
from ..._interfaces import IDilationConnector
from ..._dilation.roles import LEADER, FOLLOWER
from ...... | m | assert | variable | src/wormhole/test/dilate/test_connection.py | _test_no_relay | 132 | null | |
magic-wormhole/magic-wormhole | import os
import sys
from unittest import mock
from ..cli.public_relay import RENDEZVOUS_RELAY, TRANSIT_RELAY
from .common import config
def test_send_code_length():
cfg = config("send", "-c", "3", "fn")
assert cfg.code_length == | 3 | assert | numeric_literal | src/wormhole/test/test_args.py | test_send_code_length | 51 | null | |
magic-wormhole/magic-wormhole | import os
import sys
from unittest import mock
from ..cli.public_relay import RENDEZVOUS_RELAY, TRANSIT_RELAY
from .common import config
def test_send_text():
cfg = config("send", "--text", "hi")
assert cfg.what is None
assert cfg.text == | "hi" | assert | string_literal | src/wormhole/test/test_args.py | test_send_text | 39 | null | |
magic-wormhole/magic-wormhole | from collections import namedtuple
from itertools import cycle
from unittest import mock
from zope.interface import alsoProvides
from twisted.internet.task import Clock, Cooperator
from twisted.internet.interfaces import IPullProducer
from ...eventual import EventualQueue
from ..._interfaces import IDilationManager
fro... | s | assert | variable | src/wormhole/test/dilate/test_outbound.py | test_duplicate_registerProducer | 89 | null | |
magic-wormhole/magic-wormhole | import gc
from unittest import mock
from zope.interface import alsoProvides
import twisted.logger
from twisted.internet.task import Clock
from twisted.internet.defer import Deferred
from twisted.internet.address import IPv4Address, IPv6Address, HostnameAddress
from twisted.internet.error import ConnectError
import pyte... | 1 | assert | numeric_literal | src/wormhole/test/dilate/test_connector.py | test_connection_error | 252 | null | |
magic-wormhole/magic-wormhole | from zope.interface import alsoProvides
from twisted.internet.task import Clock, Cooperator
from twisted.internet.interfaces import IStreamServerEndpoint
from unittest import mock
import pytest
import pytest_twisted
from ...eventual import EventualQueue
from ..._interfaces import ISend, ITerminator, ISubChannel
from .... | [] | assert | collection | src/wormhole/test/dilate/test_manager.py | test_dilate_first | 68 | null | |
magic-wormhole/magic-wormhole | import io
from twisted.internet import defer
from twisted.internet.error import ConnectError
from unittest import mock
import pytest
import pytest_twisted
from .._interfaces import ITorManager
from ..errors import NoTorError
from ..tor_manager import SocksOnlyTor, get_tor
@pytest_twisted.ensureDeferred
async def te... | [mock.call(reactor, ep)] | assert | collection | src/wormhole/test/test_tor_manager.py | test_connect_custom_control_port | 127 | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.