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
qwertyquerty/pypresence
import asyncio import sys import pytest from pypresence.utils import get_event_loop, remove_none class TestRemoveNone: def test_removes_none_from_nested_dict(self): """Test removing None from nested dictionary""" d = { "level1": { "keep": "this", "remo...
"this"
assert
string_literal
tests/test_utils.py
test_removes_none_from_nested_dict
TestRemoveNone
39
null
qwertyquerty/pypresence
import json import struct from unittest.mock import AsyncMock, Mock, patch import pytest from pypresence import AioPresence, Presence from pypresence.types import ActivityType class TestPresenceUpdate: @patch("pypresence.baseclient.BaseClient.read_output") def test_update_basic(self, mock_read_output, clien...
"Test Details"
assert
string_literal
tests/test_presence.py
test_update_basic
TestPresenceUpdate
66
null
qwertyquerty/pypresence
import asyncio import json import struct import sys from unittest.mock import AsyncMock, Mock, patch import pytest from pypresence.baseclient import BaseClient from pypresence.exceptions import ( ConnectionTimeout, InvalidArgument, InvalidID, InvalidPipe, PipeClosed, PyPresenceException, R...
response
assert
variable
tests/test_baseclient.py
test_read_output_success
TestBaseClientReadOutput
156
null
qwertyquerty/pypresence
from pypresence.types import ActivityType, StatusDisplayType class TestActivityType: def test_activity_type_values(self): """Test ActivityType enum values""" assert ActivityType.PLAYING.value == 0 # STREAMING not implemented in Discord assert ActivityType.LISTENING.value ==
2
assert
numeric_literal
tests/test_types.py
test_activity_type_values
TestActivityType
13
null
qwertyquerty/pypresence
import asyncio import sys import pytest from pypresence.utils import get_event_loop, remove_none class TestRemoveNone: def test_removes_empty_nested_dicts(self): """Test that empty nested dicts are removed""" d = {"keep": "value", "nested": {"all": None, "none": None}} result = remove_no...
"value"
assert
string_literal
tests/test_utils.py
test_removes_empty_nested_dicts
TestRemoveNone
48
null
qwertyquerty/pypresence
import json import os from pypresence.payloads import Payload from pypresence.types import ActivityType, StatusDisplayType class TestPayloadGeneration: def test_payload_str_is_valid_json(self): """Test that __str__ returns valid JSON""" data = {"cmd": "TEST", "value": 123} payload = Paylo...
"TEST"
assert
string_literal
tests/test_payloads.py
test_payload_str_is_valid_json
TestPayloadGeneration
46
null
qwertyquerty/pypresence
from pypresence.types import ActivityType, StatusDisplayType class TestStatusDisplayType: def test_status_display_type_names(self): """Test StatusDisplayType names""" assert StatusDisplayType.NAME.name == "NAME" assert StatusDisplayType.STATE.name ==
"STATE"
assert
string_literal
tests/test_types.py
test_status_display_type_names
TestStatusDisplayType
61
null
qwertyquerty/pypresence
import asyncio import json import struct import sys from unittest.mock import AsyncMock, Mock, patch import pytest from pypresence.baseclient import BaseClient from pypresence.exceptions import ( ConnectionTimeout, InvalidArgument, InvalidID, InvalidPipe, PipeClosed, PyPresenceException, R...
1
assert
numeric_literal
tests/test_baseclient.py
test_send_data_with_dict
TestBaseClientSendData
115
null
qwertyquerty/pypresence
import json import os from pypresence.payloads import Payload from pypresence.types import ActivityType, StatusDisplayType class TestPayloadGeneration: def test_payload_removes_none_values(self): """Test that None values are removed by default""" data = { "cmd": "TEST", "a...
"this"
assert
string_literal
tests/test_payloads.py
test_payload_removes_none_values
TestPayloadGeneration
37
null
qwertyquerty/pypresence
import json import struct from unittest.mock import AsyncMock, Mock, patch import pytest from pypresence import AioPresence, Presence from pypresence.types import ActivityType class TestPresenceURLFeatures: @patch("pypresence.baseclient.BaseClient.read_output") def test_update_with_large_url(self, mock_read...
"large_key"
assert
string_literal
tests/test_presence.py
test_update_with_large_url
TestPresenceURLFeatures
336
null
qwertyquerty/pypresence
import asyncio import sys import pytest from pypresence.utils import get_event_loop, remove_none class TestRemoveNone: def test_preserves_falsy_non_none_values(self): """Test that other falsy values (0, False, '') are preserved""" d = { "zero": 0, "false": False, ...
0
assert
numeric_literal
tests/test_utils.py
test_preserves_falsy_non_none_values
TestRemoveNone
61
null
qwertyquerty/pypresence
from pypresence.types import ActivityType, StatusDisplayType class TestActivityType: def test_activity_type_iteration(self): """Test iterating over ActivityType""" types = list(ActivityType) assert (
4
assert
numeric_literal
tests/test_types.py
test_activity_type_iteration
TestActivityType
36
null
qwertyquerty/pypresence
import asyncio import sys import pytest from pypresence.utils import get_event_loop, remove_none class TestGetEventLoop: def test_returns_new_loop_when_forced(self): """Test force_fresh returns a new loop""" loop1 = get_event_loop(force_fresh=True) loop2 = get_event_loop(force_fresh=True...
loop2
assert
variable
tests/test_utils.py
test_returns_new_loop_when_forced
TestGetEventLoop
85
null
qwertyquerty/pypresence
from pypresence.types import ActivityType, StatusDisplayType class TestStatusDisplayType: def test_status_display_type_names(self): """Test StatusDisplayType names""" assert StatusDisplayType.NAME.name == "NAME" assert StatusDisplayType.STATE.name == "STATE" assert StatusDisplayTy...
"DETAILS"
assert
string_literal
tests/test_types.py
test_status_display_type_names
TestStatusDisplayType
62
null
qwertyquerty/pypresence
import asyncio import json import struct import sys from unittest.mock import AsyncMock, Mock, patch import pytest from pypresence.baseclient import BaseClient from pypresence.exceptions import ( ConnectionTimeout, InvalidArgument, InvalidID, InvalidPipe, PipeClosed, PyPresenceException, R...
InvalidID)
pytest.raises
variable
tests/test_baseclient.py
test_handshake_invalid_client_id
TestBaseClientHandshake
276
null
qwertyquerty/pypresence
from pypresence.types import ActivityType, StatusDisplayType class TestActivityType: def test_activity_type_names(self): """Test ActivityType names""" assert ActivityType.PLAYING.name == "PLAYING" # STREAMING not implemented in Discord assert ActivityType.LISTENING.name ==
"LISTENING"
assert
string_literal
tests/test_types.py
test_activity_type_names
TestActivityType
29
null
qwertyquerty/pypresence
import pytest from pypresence.exceptions import ( ConnectionTimeout, DiscordError, DiscordNotFound, InvalidArgument, InvalidID, InvalidPipe, PipeClosed, PyPresenceException, ResponseTimeout, ServerError, ) class TestExceptions: def test_exceptions_can_be_raised_and_caught(...
InvalidID)
pytest.raises
variable
tests/test_exceptions.py
test_exceptions_can_be_raised_and_caught
TestExceptions
64
null
qwertyquerty/pypresence
import json import struct from unittest.mock import AsyncMock, Mock, patch import pytest from pypresence import AioPresence, Presence from pypresence.types import ActivityType class TestPresenceURLFeatures: @patch("pypresence.baseclient.BaseClient.read_output") def test_update_with_large_url(self, mock_read...
"Large Image"
assert
string_literal
tests/test_presence.py
test_update_with_large_url
TestPresenceURLFeatures
337
null
qwertyquerty/pypresence
import asyncio import sys import pytest from pypresence.utils import get_event_loop, remove_none class TestIPCPath: @pytest.mark.skipif(sys.platform == "win32", reason="Unix-specific test") def test_unix_ipc_path_format(self): """Test Unix IPC path format""" from pypresence.utils import get_...
path
assert
variable
tests/test_utils.py
test_unix_ipc_path_format
TestIPCPath
152
null
qwertyquerty/pypresence
from pypresence.types import ActivityType, StatusDisplayType class TestStatusDisplayType: def test_status_display_type_values(self): """Test StatusDisplayType enum values""" assert StatusDisplayType.NAME.value == 0 assert StatusDisplayType.STATE.value ==
1
assert
numeric_literal
tests/test_types.py
test_status_display_type_values
TestStatusDisplayType
49
null
qwertyquerty/pypresence
import json import os from pypresence.payloads import Payload from pypresence.types import ActivityType, StatusDisplayType class TestSetActivityURLFeatures: def test_set_activity_urls_none_are_removed(self): """Test that URL fields with None values are removed""" payload = Payload.set_activity( ...
"Details"
assert
string_literal
tests/test_payloads.py
test_set_activity_urls_none_are_removed
TestSetActivityURLFeatures
325
null
qwertyquerty/pypresence
import asyncio import json import struct import sys from unittest.mock import AsyncMock, Mock, patch import pytest from pypresence.baseclient import BaseClient from pypresence.exceptions import ( ConnectionTimeout, InvalidArgument, InvalidID, InvalidPipe, PipeClosed, PyPresenceException, R...
PipeClosed)
pytest.raises
variable
tests/test_baseclient.py
test_read_output_broken_pipe
TestBaseClientReadOutput
180
null
qwertyquerty/pypresence
import json import struct from unittest.mock import AsyncMock, Mock, patch import pytest from pypresence import AioPresence, Presence from pypresence.types import ActivityType class TestPresenceInit: def test_presence_init_basic(self, client_id): """Test basic Presence initialization""" presence...
client_id
assert
variable
tests/test_presence.py
test_presence_init_basic
TestPresenceInit
20
null
qwertyquerty/pypresence
from pypresence.types import ActivityType, StatusDisplayType class TestActivityType: def test_activity_type_values(self): """Test ActivityType enum values""" assert ActivityType.PLAYING.value ==
0
assert
numeric_literal
tests/test_types.py
test_activity_type_values
TestActivityType
11
null
qwertyquerty/pypresence
import asyncio import json import struct import sys from unittest.mock import AsyncMock, Mock, patch import pytest from pypresence.baseclient import BaseClient from pypresence.exceptions import ( ConnectionTimeout, InvalidArgument, InvalidID, InvalidPipe, PipeClosed, PyPresenceException, R...
10
assert
numeric_literal
tests/test_baseclient.py
test_init_basic
TestBaseClientInit
34
null
qwertyquerty/pypresence
import json import os from pypresence.payloads import Payload from pypresence.types import ActivityType, StatusDisplayType class TestSetActivity: def test_set_activity_basic(self): """Test basic activity payload""" payload = Payload.set_activity(state="Testing", details="Running tests") ...
"Testing"
assert
string_literal
tests/test_payloads.py
test_set_activity_basic
TestSetActivity
58
null
qwertyquerty/pypresence
import asyncio import sys import pytest from pypresence.utils import get_event_loop, remove_none class TestGetEventLoop: async def check_loop(): loop = get_event_loop() running = asyncio.get_running_loop() assert loop is
running
assert
variable
tests/test_utils.py
check_loop
TestGetEventLoop
98
null
qwertyquerty/pypresence
import pytest from pypresence.exceptions import ( ConnectionTimeout, DiscordError, DiscordNotFound, InvalidArgument, InvalidID, InvalidPipe, PipeClosed, PyPresenceException, ResponseTimeout, ServerError, ) class TestExceptions: def test_invalid_argument_exception(self): ...
str(exc)
assert
func_call
tests/test_exceptions.py
test_invalid_argument_exception
TestExceptions
32
null
qwertyquerty/pypresence
import asyncio import sys import pytest from pypresence.utils import get_event_loop, remove_none class TestGetEventLoop: def test_returns_new_loop_if_current_closed(self): """Test returns new loop if current loop is closed""" old_loop = asyncio.new_event_loop() asyncio.set_event_loop(old...
old_loop
assert
variable
tests/test_utils.py
test_returns_new_loop_if_current_closed
TestGetEventLoop
125
null
qwertyquerty/pypresence
import asyncio import json import struct import sys from unittest.mock import AsyncMock, Mock, patch import pytest from pypresence.baseclient import BaseClient from pypresence.exceptions import ( ConnectionTimeout, InvalidArgument, InvalidID, InvalidPipe, PipeClosed, PyPresenceException, R...
30
assert
numeric_literal
tests/test_baseclient.py
test_init_basic
TestBaseClientInit
33
null
qwertyquerty/pypresence
import pytest from pypresence.exceptions import ( ConnectionTimeout, DiscordError, DiscordNotFound, InvalidArgument, InvalidID, InvalidPipe, PipeClosed, PyPresenceException, ResponseTimeout, ServerError, ) class TestExceptions: def test_exceptions_can_be_raised_and_caught(...
ResponseTimeout)
pytest.raises
variable
tests/test_exceptions.py
test_exceptions_can_be_raised_and_caught
TestExceptions
58
null
qwertyquerty/pypresence
from pypresence.types import ActivityType, StatusDisplayType class TestActivityType: def test_activity_type_iteration(self): """Test iterating over ActivityType""" types = list(ActivityType) assert ( len(types) == 4 ) # Only 4 implemented: PLAYING, LISTENING, WATCHING,...
types
assert
variable
tests/test_types.py
test_activity_type_iteration
TestActivityType
39
null
qwertyquerty/pypresence
import json import struct from unittest.mock import AsyncMock, Mock, patch import pytest from pypresence import AioPresence, Presence from pypresence.types import ActivityType class TestPresenceInit: def test_presence_init_basic(self, client_id): """Test basic Presence initialization""" presence...
30
assert
numeric_literal
tests/test_presence.py
test_presence_init_basic
TestPresenceInit
22
null
qwertyquerty/pypresence
import json import os from pypresence.payloads import Payload from pypresence.types import ActivityType, StatusDisplayType class TestSetActivity: def test_set_activity_with_timestamps(self): """Test activity with start/end timestamps""" start_time = 1234567890 end_time = 1234567900 ...
start_time
assert
variable
tests/test_payloads.py
test_set_activity_with_timestamps
TestSetActivity
69
null
qwertyquerty/pypresence
import asyncio import json import struct import sys from unittest.mock import AsyncMock, Mock, patch import pytest from pypresence.baseclient import BaseClient from pypresence.exceptions import ( ConnectionTimeout, InvalidArgument, InvalidID, InvalidPipe, PipeClosed, PyPresenceException, R...
ResponseTimeout)
pytest.raises
variable
tests/test_baseclient.py
test_read_output_timeout
TestBaseClientReadOutput
190
null
qwertyquerty/pypresence
import asyncio import json import struct import sys from unittest.mock import AsyncMock, Mock, patch import pytest from pypresence.baseclient import BaseClient from pypresence.exceptions import ( ConnectionTimeout, InvalidArgument, InvalidID, InvalidPipe, PipeClosed, PyPresenceException, R...
InvalidArgument)
pytest.raises
variable
tests/test_baseclient.py
test_init_with_async_handler_requires_coroutine
TestBaseClientInit
93
null
qwertyquerty/pypresence
import json import struct from unittest.mock import AsyncMock, Mock, patch import pytest from pypresence import AioPresence, Presence from pypresence.types import ActivityType class TestPresenceInit: def test_presence_init_with_pipe(self, client_id): """Test Presence with specific pipe""" presen...
5
assert
numeric_literal
tests/test_presence.py
test_presence_init_with_pipe
TestPresenceInit
36
null
qwertyquerty/pypresence
import json import os from pypresence.payloads import Payload from pypresence.types import ActivityType, StatusDisplayType class TestSetActivity: def test_set_activity_with_activity_type_int(self): """Test activity type can be specified as int""" payload = Payload.set_activity(activity_type=2) #...
2
assert
numeric_literal
tests/test_payloads.py
test_set_activity_with_activity_type_int
TestSetActivity
126
null
qwertyquerty/pypresence
import json import os from pypresence.payloads import Payload from pypresence.types import ActivityType, StatusDisplayType class TestSetActivity: def test_set_activity_with_party(self): """Test activity with party information""" payload = Payload.set_activity(party_id="party123", party_size=[1, 5...
"party123"
assert
string_literal
tests/test_payloads.py
test_set_activity_with_party
TestSetActivity
92
null
piskvorky/smart_open
import gzip import io import logging import os import time import uuid import unittest from collections import OrderedDict import smart_open import smart_open.constants import azure.storage.blob import azure.common import azure.core.exceptions CONTAINER_NAME = 'test-smartopen-{}'.format(uuid.uuid4().hex) BLOB_NAME =...
i)
self.assertEqual
variable
tests/test_azure.py
test_write_03a
WriterTest
769
null
piskvorky/smart_open
from collections import defaultdict import functools import random import gzip import io import re import logging import os import tempfile import unittest import warnings from contextlib import contextmanager from unittest import mock import sys import boto3 import botocore.client import botocore.endpoint import boto...
1)
assert_*
numeric_literal
tests/test_s3.py
test_every_second_read_fails
IncrementalBackoffTest
213
null
piskvorky/smart_open
import functools import gzip import unittest import pytest import responses import smart_open.http import smart_open.s3 import smart_open.constants import requests BYTES = b'i tried so hard and got so far but in the end it doesn\'t even matter' GZIPPED_BYTES = gzip.compress(BYTES) URL = 'http://localhost' HTTPS_URL ...
session
assert
variable
tests/test_http.py
test_session_attribute
HttpTest
168
null
piskvorky/smart_open
import gzip import io import logging import os import time import uuid import unittest from collections import OrderedDict import smart_open import smart_open.constants import azure.storage.blob import azure.common import azure.core.exceptions CONTAINER_NAME = 'test-smartopen-{}'.format(uuid.uuid4().hex) BLOB_NAME =...
[])
self.assertEqual
collection
tests/test_azure.py
test_delete_blob
FakeBlobClientTest
100
null
piskvorky/smart_open
import functools import logging import unittest import uuid import time import boto3 from smart_open import open BUCKET_NAME = 'test-smartopen' KEY_NAME = 'test-key' logger = logging.getLogger(__name__) _resource = functools.partial(boto3.resource, region_name='us-east-1') def get_versions(bucket, key): """Re...
self.test_ver2)
self.assertEqual
complex_expr
tests/test_s3_version.py
test_no_version
TestVersionId
91
null
piskvorky/smart_open
import urllib.parse import pytest import smart_open.utils @pytest.mark.parametrize( 'value,minval,maxval,expected', [ (5, 0, 10, 5), (11, 0, 10, 10), (-1, 0, 10, 0), (10, 0, None, 10), (-10, 0, None, 0), ] ) def test_clamp(value, minval, maxval, expected): ass...
expected
assert
variable
tests/test_utils.py
test_clamp
26
null
piskvorky/smart_open
import gzip import io import logging import os import time import uuid import unittest from collections import OrderedDict import smart_open import smart_open.constants import azure.storage.blob import azure.common import azure.core.exceptions CONTAINER_NAME = 'test-smartopen-{}'.format(uuid.uuid4().hex) BLOB_NAME =...
b'')
self.assertEqual
string_literal
tests/test_azure.py
test_read0_does_not_return_data
ReaderTest
520
null
piskvorky/smart_open
import bz2 import csv import contextlib import functools import io import gzip import hashlib import logging import os from smart_open.compression import INFER_FROM_EXTENSION, NO_COMPRESSION import tempfile import unittest from unittest import mock import warnings import boto3 import pytest import responses import sm...
"r")
assert_*
string_literal
tests/test_smart_open.py
test_text
SmartOpenTest
1,207
null
piskvorky/smart_open
import io import os import urllib.parse import google.cloud.storage import smart_open _GCS_URL = os.environ.get('SO_GCS_URL') def initialize_bucket(): client = google.cloud.storage.Client() parsed = urllib.parse.urlparse(_GCS_URL) bucket_name = parsed.netloc prefix = parsed.path bucket = client....
binary
assert
variable
integration-tests/test_gcs.py
test_gcs_readwrite_binary
69
null
piskvorky/smart_open
from collections import defaultdict import functools import random import gzip import io import re import logging import os import tempfile import unittest import warnings from contextlib import contextmanager from unittest import mock import sys import boto3 import botocore.client import botocore.endpoint import boto...
1
assert
numeric_literal
tests/test_s3.py
test_write_03
MultipartWriterTest
598
null
piskvorky/smart_open
import gzip import io import logging import os import time import uuid import unittest from collections import OrderedDict import smart_open import smart_open.constants import azure.storage.blob import azure.common import azure.core.exceptions CONTAINER_NAME = 'test-smartopen-{}'.format(uuid.uuid4().hex) BLOB_NAME =...
6)
self.assertEqual
numeric_literal
tests/test_azure.py
test_seek_start
ReaderTest
412
null
piskvorky/smart_open
import bz2 import csv import contextlib import functools import io import gzip import hashlib import logging import os from smart_open.compression import INFER_FROM_EXTENSION, NO_COMPRESSION import tempfile import unittest from unittest import mock import warnings import boto3 import pytest import responses import sm...
1)
self.assertEqual
numeric_literal
tests/test_smart_open.py
test_http_pass
SmartOpenHttpTest
514
null
piskvorky/smart_open
import gzip import io import logging import os import time import uuid import unittest from collections import OrderedDict import smart_open import smart_open.constants import azure.storage.blob import azure.common import azure.core.exceptions CONTAINER_NAME = 'test-smartopen-{}'.format(uuid.uuid4().hex) BLOB_NAME =...
1)
self.assertEqual
numeric_literal
tests/test_azure.py
test_write_03
WriterTest
739
null
piskvorky/smart_open
import bz2 import csv import contextlib import functools import io import gzip import hashlib import logging import os from smart_open.compression import INFER_FROM_EXTENSION, NO_COMPRESSION import tempfile import unittest from unittest import mock import warnings import boto3 import pytest import responses import sm...
4
assert
numeric_literal
tests/test_smart_open.py
test_write
WebHdfsWriteTest
1,458
null
piskvorky/smart_open
import io import random import unittest import smart_open.bytebuffer CHUNK_SIZE = 1024 def int2byte(i): return bytes((i, )) def random_byte_string(length=CHUNK_SIZE): rand_bytes = [int2byte(random.randint(0, 255)) for _ in range(length)] return b''.join(rand_bytes) def bytebuffer_and_random_contents():...
CHUNK_SIZE)
self.assertEqual
variable
tests/test_bytebuffer.py
test_fill_from_reader
ByteBufferTest
55
null
piskvorky/smart_open
from __future__ import unicode_literals import contextlib import io import os import random import string import boto3 import smart_open _BUCKET = os.environ.get('SO_BUCKET') _KEY = os.environ.get('SO_KEY') def _random_string(length=8): alphabet = string.ascii_lowercase + string.digits return ''.join(random...
binary
assert
variable
integration-tests/test_s3.py
test_s3_readwrite_binary
92
null
piskvorky/smart_open
import contextlib import gzip import io import os import unittest import uuid import warnings import boto3 import pytest import smart_open import smart_open.concurrency import smart_open.constants from initialize_s3_bucket import CONTENTS BUCKET_NAME = 'smartopen-integration-tests' def setUpModule(): assert bot...
2
assert
numeric_literal
integration-tests/test_s3_ported.py
test_multipart
WriterTest
245
null
piskvorky/smart_open
import bz2 import csv import contextlib import functools import io import gzip import hashlib import logging import os from smart_open.compression import INFER_FROM_EXTENSION, NO_COMPRESSION import tempfile import unittest from unittest import mock import warnings import boto3 import pytest import responses import sm...
"")
self.assertEqual
string_literal
tests/test_smart_open.py
test_uri_from_issue_223_works
ParseUriTest
260
null
piskvorky/smart_open
import functools import gzip import unittest import pytest import responses import smart_open.http import smart_open.s3 import smart_open.constants import requests BYTES = b'i tried so hard and got so far but in the end it doesn\'t even matter' GZIPPED_BYTES = gzip.compress(BYTES) URL = 'http://localhost' HTTPS_URL ...
40)
self.assertEqual
numeric_literal
tests/test_http.py
test_seek_from_current
HttpTest
84
null
piskvorky/smart_open
import os import unittest import pytest from smart_open import open skip_tests = "SMART_OPEN_TEST_MISSING_DEPS" not in os.environ class PackageTests(unittest.TestCase): @pytest.mark.skipif(skip_tests, reason="requires missing dependencies") def test_gcs_raises_helpful_error_with_missing_deps(self): ...
ImportError, match=r"pip install smart_open\[gcs\]")
pytest.raises
complex_expr
tests/test_package.py
test_gcs_raises_helpful_error_with_missing_deps
PackageTests
26
null
piskvorky/smart_open
import functools import logging import unittest import uuid import time import boto3 from smart_open import open BUCKET_NAME = 'test-smartopen' KEY_NAME = 'test-key' logger = logging.getLogger(__name__) _resource = functools.partial(boto3.resource, region_name='us-east-1') def get_versions(bucket, key): """Re...
ValueError)
self.assertRaises
variable
tests/test_s3_version.py
test_bad_mode
TestVersionId
84
null
piskvorky/smart_open
import bz2 import csv import contextlib import functools import io import gzip import hashlib import logging import os from smart_open.compression import INFER_FROM_EXTENSION, NO_COMPRESSION import tempfile import unittest from unittest import mock import warnings import boto3 import pytest import responses import sm...
4)
self.assertEqual
numeric_literal
tests/test_smart_open.py
test_s3_tell
SmartOpenReadTest
1,127
null
piskvorky/smart_open
import functools import gzip import unittest import pytest import responses import smart_open.http import smart_open.s3 import smart_open.constants import requests BYTES = b'i tried so hard and got so far but in the end it doesn\'t even matter' GZIPPED_BYTES = gzip.compress(BYTES) URL = 'http://localhost' HTTPS_URL ...
10)
self.assertEqual
numeric_literal
tests/test_http.py
test_seek_from_start
HttpTest
58
null
piskvorky/smart_open
import contextlib import gzip import io import os import unittest import uuid import warnings import boto3 import pytest import smart_open import smart_open.concurrency import smart_open.constants from initialize_s3_bucket import CONTENTS BUCKET_NAME = 'smartopen-integration-tests' def setUpModule(): assert bot...
actual)
self.assertEqual
variable
integration-tests/test_s3_ported.py
test_iter
ReaderTest
53
null
piskvorky/smart_open
import functools import logging import unittest import uuid import time import boto3 from smart_open import open BUCKET_NAME = 'test-smartopen' KEY_NAME = 'test-key' logger = logging.getLogger(__name__) _resource = functools.partial(boto3.resource, region_name='us-east-1') def get_versions(bucket, key): """Re...
IOError)
self.assertRaises
variable
tests/test_s3_version.py
test_bad_id
TestVersionId
78
null
piskvorky/smart_open
import io import logging import os import uuid import unittest from unittest import mock import warnings from collections import OrderedDict import google.cloud import google.api_core.exceptions import smart_open import smart_open.constants BUCKET_NAME = 'test-smartopen-{}'.format(uuid.uuid4().hex) BLOB_NAME = 'test...
'wb')
assert_*
string_literal
tests/test_gcs.py
test_default_open_kwargs
WriterTest
317
null
piskvorky/smart_open
import io import random import unittest import smart_open.bytebuffer CHUNK_SIZE = 1024 def int2byte(i): return bytes((i, )) def random_byte_string(length=CHUNK_SIZE): rand_bytes = [int2byte(random.randint(0, 255)) for _ in range(length)] return b''.join(rand_bytes) def bytebuffer_and_random_contents():...
actual)
self.assertEqual
variable
tests/test_bytebuffer.py
test_readline_terminator
ByteBufferTest
191
null
piskvorky/smart_open
import functools import gzip import unittest import pytest import responses import smart_open.http import smart_open.s3 import smart_open.constants import requests BYTES = b'i tried so hard and got so far but in the end it doesn\'t even matter' GZIPPED_BYTES = gzip.compress(BYTES) URL = 'http://localhost' HTTPS_URL ...
BYTES
assert
variable
tests/test_http.py
test_gzip_encoding_default_headers
209
null
piskvorky/smart_open
import contextlib import gzip import io import os import unittest import uuid import warnings import boto3 import pytest import smart_open import smart_open.concurrency import smart_open.constants from initialize_s3_bucket import CONTENTS BUCKET_NAME = 'smartopen-integration-tests' def setUpModule(): assert bot...
6)
self.assertEqual
numeric_literal
integration-tests/test_s3_ported.py
test_seek_start
ReaderTest
93
null
piskvorky/smart_open
import functools import logging import unittest import uuid import time import boto3 from smart_open import open BUCKET_NAME = 'test-smartopen' KEY_NAME = 'test-key' logger = logging.getLogger(__name__) _resource = functools.partial(boto3.resource, region_name='us-east-1') def get_versions(bucket, key): """Re...
self.test_ver1)
self.assertEqual
complex_expr
tests/test_s3_version.py
test_good_id
TestVersionId
73
null
piskvorky/smart_open
import bz2 import csv import contextlib import functools import io import gzip import hashlib import logging import os from smart_open.compression import INFER_FROM_EXTENSION, NO_COMPRESSION import tempfile import unittest from unittest import mock import warnings import boto3 import pytest import responses import sm...
2)
self.assertEqual
numeric_literal
tests/test_smart_open.py
test_s3_iter_lines
SmartOpenReadTest
936
null
piskvorky/smart_open
import urllib.parse import pytest import smart_open.utils def test_check_kwargs(): import smart_open.s3 kallable = smart_open.s3.open kwargs = {'client': 'foo', 'unsupported': 'bar', 'client_kwargs': 'boaz'} supported = smart_open.utils.check_kwargs(kallable, kwargs) assert supported ==
{'client': 'foo', 'client_kwargs': 'boaz'}
assert
collection
tests/test_utils.py
test_check_kwargs
47
null
piskvorky/smart_open
import json import os import smart_open from smart_open.webhdfs import WebHdfsException import pytest _SO_WEBHDFS_BASE_URL = os.environ.get("SO_WEBHDFS_BASE_URL") def make_url(path): return "{base_url}/{path}".format( base_url=_SO_WEBHDFS_BASE_URL.rstrip("/"), path=path.lstrip("/") ) def test_write_a...
"write_test\n"
assert
string_literal
integration-tests/test_webhdfs.py
test_write_and_read
42
null
piskvorky/smart_open
import contextlib import gzip import io import os import unittest import uuid import warnings import boto3 import pytest import smart_open import smart_open.concurrency import smart_open.constants from initialize_s3_bucket import CONTENTS BUCKET_NAME = 'smartopen-integration-tests' def setUpModule(): assert bot...
0
assert
numeric_literal
integration-tests/test_s3_ported.py
test_multipart
WriterTest
244
null
piskvorky/smart_open
import pytest import unittest from smart_open.transport import register_transport, get_transport class TransportTest(unittest.TestCase): def test_registry_requires_declared_schemes(self): with pytest.raises(
ValueError)
pytest.raises
variable
tests/test_transport.py
test_registry_requires_declared_schemes
TransportTest
11
null
piskvorky/smart_open
import io import os import urllib.parse import google.cloud.storage import smart_open _GCS_URL = os.environ.get('SO_GCS_URL') def initialize_bucket(): client = google.cloud.storage.Client() parsed = urllib.parse.urlparse(_GCS_URL) bucket_name = parsed.netloc prefix = parsed.path bucket = client....
one_megabyte
assert
variable
integration-tests/test_gcs.py
test_gcs_performance
91
null
piskvorky/smart_open
import contextlib import gzip import io import os import unittest import uuid import warnings import boto3 import pytest import smart_open import smart_open.concurrency import smart_open.constants from initialize_s3_bucket import CONTENTS BUCKET_NAME = 'smartopen-integration-tests' def setUpModule(): assert bot...
b'')
self.assertEqual
string_literal
integration-tests/test_s3_ported.py
test_read0_does_not_return_data
ReaderTest
167
null
piskvorky/smart_open
from smart_open import open def read_bytes(url, limit): bytes_ = [] with open(url, 'rb') as fin: for i in range(limit): bytes_.append(fin.read(1)) return bytes_ def test(benchmark): # # This file is around 850MB. # url = ( 's3://commoncrawl/crawl-data/CC-MAIN-2...
limit
assert
variable
integration-tests/test_s3_buffering.py
test
23
null
piskvorky/smart_open
from __future__ import unicode_literals import logging import unittest import smart_open GZIP_MAGIC = b'\x1f\x8b' BASE_URL = ('https://raw.githubusercontent.com/RaRe-Technologies/smart_open/' 'master/tests/test_data/') class ReadTest(unittest.TestCase): def test_read_text(self): url = BASE_U...
text.endswith('улизнуть, чтобы никто не видал.\n'))
self.assertTrue
func_call
integration-tests/test_http.py
test_read_text
ReadTest
26
null
piskvorky/smart_open
import bz2 import csv import contextlib import functools import io import gzip import hashlib import logging import os from smart_open.compression import INFER_FROM_EXTENSION, NO_COMPRESSION import tempfile import unittest from unittest import mock import warnings import boto3 import pytest import responses import sm...
443)
self.assertEqual
numeric_literal
tests/test_smart_open.py
test_s3_uri_has_atmark_in_key_name3
ParseUriTest
206
null
piskvorky/smart_open
import functools import gzip import unittest import pytest import responses import smart_open.http import smart_open.s3 import smart_open.constants import requests BYTES = b'i tried so hard and got so far but in the end it doesn\'t even matter' GZIPPED_BYTES = gzip.compress(BYTES) URL = 'http://localhost' HTTPS_URL ...
'bar')
self.assertEqual
string_literal
tests/test_http.py
test_headers
HttpTest
120
null
piskvorky/smart_open
from __future__ import unicode_literals import gzip import pytest from smart_open import open import ssl from functools import partial ssl.create_default_context = partial(ssl.create_default_context, cafile="/etc/vsftpd.pem") def server_info(request): return request.param def test_line_endings_non_binary(server_...
line
assert
variable
integration-tests/test_ftp.py
test_line_endings_non_binary
105
null
piskvorky/smart_open
import io import logging import os import uuid import unittest from unittest import mock import warnings from collections import OrderedDict import google.cloud import google.api_core.exceptions import smart_open import smart_open.constants BUCKET_NAME = 'test-smartopen-{}'.format(uuid.uuid4().hex) BLOB_NAME = 'test...
BLOB_NAME)
assert_*
variable
tests/test_gcs.py
test_get_blob_kwargs_passthrough
WriterTest
311
null
piskvorky/smart_open
import bz2 import gzip import io import lzma import sys import pytest import smart_open.compression plain = 'доброе утро планета!'.encode() def label(thing, name): setattr(thing, 'name', name) return thing @pytest.mark.parametrize( 'fileobj,compression,filename', [ (io.BytesIO(plain), 'disa...
plain
assert
variable
tests/test_compression.py
test_compression_wrapper_read
59
null
piskvorky/smart_open
import boto3 from smart_open import open BUCKET, KEY = 'smart-open-versioned', 'demo.txt' URL = 's3://%s/%s' % (BUCKET, KEY) def assert_equal(a, b): assert a == b, '%r != %r' % (a, b) def main(): versions = [ v.id for v in boto3.resource('s3').Bucket(BUCKET).object_versions.filter(Prefix=KEY) ] ...
expected_versions)
assert_*
variable
integration-tests/test_version_id.py
main
24
null
piskvorky/smart_open
from __future__ import unicode_literals import gzip import pytest from smart_open import open import ssl from functools import partial ssl.create_default_context = partial(ssl.create_default_context, cafile="/etc/vsftpd.pem") def server_info(request): return request.param def test_nonbinary(server_info): ser...
file_contents + appended_content1
assert
complex_expr
integration-tests/test_ftp.py
test_nonbinary
34
null
piskvorky/smart_open
import os import unittest import pytest from smart_open import open skip_tests = "SMART_OPEN_TEST_MISSING_DEPS" not in os.environ class PackageTests(unittest.TestCase): @pytest.mark.skipif(skip_tests, reason="requires missing dependencies") def test_aws_raises_helpful_error_with_missing_deps(self): ...
ImportError, match=match)
pytest.raises
complex_expr
tests/test_package.py
test_aws_raises_helpful_error_with_missing_deps
PackageTests
21
null
piskvorky/smart_open
import functools import gzip import unittest import pytest import responses import smart_open.http import smart_open.s3 import smart_open.constants import requests BYTES = b'i tried so hard and got so far but in the end it doesn\'t even matter' GZIPPED_BYTES = gzip.compress(BYTES) URL = 'http://localhost' HTTPS_URL ...
30)
self.assertEqual
numeric_literal
tests/test_http.py
test_seek_from_current
HttpTest
82
null
piskvorky/smart_open
import functools import gzip import unittest import pytest import responses import smart_open.http import smart_open.s3 import smart_open.constants import requests BYTES = b'i tried so hard and got so far but in the end it doesn\'t even matter' GZIPPED_BYTES = gzip.compress(BYTES) URL = 'http://localhost' HTTPS_URL ...
20)
self.assertEqual
numeric_literal
tests/test_http.py
test_seek_from_start
HttpTest
60
null
piskvorky/smart_open
import functools import gzip import unittest import pytest import responses import smart_open.http import smart_open.s3 import smart_open.constants import requests BYTES = b'i tried so hard and got so far but in the end it doesn\'t even matter' GZIPPED_BYTES = gzip.compress(BYTES) URL = 'http://localhost' HTTPS_URL ...
b""
assert
string_literal
tests/test_http.py
test_read_after_read_to_eof
252
null
piskvorky/smart_open
import logging import os import unittest from unittest import mock from paramiko import SSHException import smart_open.ssh _TEST_DATA_PATH = os.path.join(os.path.dirname(__file__), "test_data") _CONFIG_PATH = os.path.join(_TEST_DATA_PATH, "ssh.cfg") def mock_ssh(func): def wrapper(*args, **kwargs): smar...
2345)
assert_*
numeric_literal
tests/test_ssh.py
test_open_with_openssh_config
SSHOpen
85
null
piskvorky/smart_open
from __future__ import unicode_literals import logging import unittest import smart_open GZIP_MAGIC = b'\x1f\x8b' BASE_URL = ('https://raw.githubusercontent.com/RaRe-Technologies/smart_open/' 'master/tests/test_data/') class ReadTest(unittest.TestCase): def test_read_gzip_binary(self): url ...
binary.startswith(GZIP_MAGIC))
self.assertTrue
func_call
integration-tests/test_http.py
test_read_gzip_binary
ReadTest
46
null
piskvorky/smart_open
import io import logging import os import uuid import unittest from unittest import mock import warnings from collections import OrderedDict import google.cloud import google.api_core.exceptions import smart_open import smart_open.constants BUCKET_NAME = 'test-smartopen-{}'.format(uuid.uuid4().hex) BLOB_NAME = 'test...
blob_two)
self.assertEqual
variable
tests/test_gcs.py
test_get_multiple_blobs
FakeBucketTest
114
null
piskvorky/smart_open
from __future__ import unicode_literals import contextlib import io import os import random import string import boto3 import smart_open _BUCKET = os.environ.get('SO_BUCKET') _KEY = os.environ.get('SO_KEY') def _random_string(length=8): alphabet = string.ascii_lowercase + string.digits return ''.join(random...
one_megabyte
assert
variable
integration-tests/test_s3.py
test_s3_performance
110
null
piskvorky/smart_open
import io import os import azure.storage.blob from pytest import fixture import smart_open _AZURE_CONTAINER = os.environ.get('SO_AZURE_CONTAINER') _AZURE_STORAGE_CONNECTION_STRING = os.environ.get('AZURE_STORAGE_CONNECTION_STRING') _FILE_PREFIX = '%s://%s' % (smart_open.azure.SCHEME, _AZURE_CONTAINER) def client()...
one_megabyte
assert
variable
integration-tests/test_azure.py
test_azure_performance
103
null
piskvorky/smart_open
from collections import defaultdict import functools import random import gzip import io import re import logging import os import tempfile import unittest import warnings from contextlib import contextmanager from unittest import mock import sys import boto3 import botocore.client import botocore.endpoint import boto...
2
assert
numeric_literal
tests/test_s3.py
test_write_03
MultipartWriterTest
612
null
piskvorky/smart_open
import io import random import unittest import smart_open.bytebuffer CHUNK_SIZE = 1024 def int2byte(i): return bytes((i, )) def random_byte_string(length=CHUNK_SIZE): rand_bytes = [int2byte(random.randint(0, 255)) for _ in range(length)] return b''.join(rand_bytes) def bytebuffer_and_random_contents():...
fill_size)
self.assertEqual
variable
tests/test_bytebuffer.py
test_fill_size
ByteBufferTest
99
null
piskvorky/smart_open
import functools import gzip import unittest import pytest import responses import smart_open.http import smart_open.s3 import smart_open.constants import requests BYTES = b'i tried so hard and got so far but in the end it doesn\'t even matter' GZIPPED_BYTES = gzip.compress(BYTES) URL = 'http://localhost' HTTPS_URL ...
len(BYTES)
assert
func_call
tests/test_http.py
test_read_after_read_to_eof
247
null
piskvorky/smart_open
import io import os import azure.storage.blob from pytest import fixture import smart_open _AZURE_CONTAINER = os.environ.get('SO_AZURE_CONTAINER') _AZURE_STORAGE_CONNECTION_STRING = os.environ.get('AZURE_STORAGE_CONNECTION_STRING') _FILE_PREFIX = '%s://%s' % (smart_open.azure.SCHEME, _AZURE_CONTAINER) def client()...
text
assert
variable
integration-tests/test_azure.py
test_azure_readwrite_text
61
null
piskvorky/smart_open
import bz2 import csv import contextlib import functools import io import gzip import hashlib import logging import os from smart_open.compression import INFER_FROM_EXTENSION, NO_COMPRESSION import tempfile import unittest from unittest import mock import warnings import boto3 import pytest import responses import sm...
'r')
assert_*
string_literal
tests/test_smart_open.py
test_shortcut
SmartOpenReadTest
653
null
piskvorky/smart_open
import io import logging import os import uuid import unittest from unittest import mock import warnings from collections import OrderedDict import google.cloud import google.api_core.exceptions import smart_open import smart_open.constants BUCKET_NAME = 'test-smartopen-{}'.format(uuid.uuid4().hex) BLOB_NAME = 'test...
expected)
self.assertEqual
variable
tests/test_gcs.py
test_blob_registers_with_bucket
FakeBucketTest
91
null