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 |
|---|---|---|---|---|---|---|---|---|---|
meta-llama/synthetic-data-kit | from pathlib import Path
import pytest
from synthetic_data_kit.utils import config, text
@pytest.mark.unit
def test_split_into_chunks():
"""Test splitting text into chunks."""
# Create multi-paragraph text
paragraphs = ["Paragraph one." * 5, "Paragraph two." * 5, "Paragraph three." * 5]
text_content ... | 2 | assert | numeric_literal | tests/unit/test_utils.py | test_split_into_chunks | 24 | null | |
meta-llama/synthetic-data-kit | from unittest.mock import MagicMock, patch
import pytest
from synthetic_data_kit.models.llm_client import LLMClient
@pytest.mark.unit
def test_llm_client_vllm_initialization(patch_config, test_env):
"""Test LLM client initialization with vLLM provider."""
with patch("requests.get") as mock_get:
mock_... | "vllm" | assert | string_literal | tests/unit/test_llm_client.py | test_llm_client_vllm_initialization | 41 | null | |
meta-llama/synthetic-data-kit | from unittest.mock import MagicMock, patch
import pytest
from synthetic_data_kit.models.llm_client import LLMClient
@pytest.mark.unit
def test_llm_client_initialization(patch_config, test_env):
"""Test LLM client initialization with API endpoint provider."""
with patch("synthetic_data_kit.models.llm_client.O... | None | assert | none_literal | tests/unit/test_llm_client.py | test_llm_client_initialization | 22 | null | |
meta-llama/synthetic-data-kit | import json
import os
import tempfile
from unittest.mock import MagicMock, patch
import pytest
from synthetic_data_kit.utils.format_converter import (
to_alpaca,
to_chatml,
to_fine_tuning,
to_hf_dataset,
to_jsonl,
)
@pytest.mark.unit
def test_to_jsonl():
"""Test conversion to JSONL format."""... | output_path | assert | variable | tests/unit/test_format_converter.py | test_to_jsonl | 43 | null | |
meta-llama/synthetic-data-kit | from pathlib import Path
import pytest
from synthetic_data_kit.utils import config, text
@pytest.mark.unit
def test_load_config(tmpdir):
"""Test loading config from file."""
# Create a temporary config file
config_path = Path(tmpdir) / "test_config.yaml"
with open(config_path, "w") as f:
f.w... | "http://test-api.com" | assert | string_literal | tests/unit/test_utils.py | test_load_config | 113 | null | |
meta-llama/synthetic-data-kit | import os
import tempfile
import json
from unittest.mock import patch, MagicMock
import pytest
@pytest.mark.integration
def test_single_file_with_name_option():
"""Test that --name option still works for single files."""
with tempfile.NamedTemporaryFile(mode="w", suffix=".txt", delete=False) as f:
f.w... | custom_name | assert | variable | tests/integration/test_backward_compatibility.py | test_single_file_with_name_option | 195 | null | |
meta-llama/synthetic-data-kit | import json
import os
import tempfile
from unittest.mock import MagicMock, patch
import pytest
from synthetic_data_kit.utils.format_converter import (
to_alpaca,
to_chatml,
to_fine_tuning,
to_hf_dataset,
to_jsonl,
)
@pytest.mark.unit
def test_to_jsonl():
"""Test conversion to JSONL format."""... | 2 | assert | numeric_literal | tests/unit/test_format_converter.py | test_to_jsonl | 53 | null | |
meta-llama/synthetic-data-kit | import os
import tempfile
import json
from unittest.mock import patch, MagicMock
import pytest
from synthetic_data_kit.utils.directory_processor import (
process_directory_ingest,
process_directory_save_as,
get_directory_stats,
INGEST_EXTENSIONS,
SAVE_AS_EXTENSIONS
)
@pytest.mark.integration
def ... | 1 | assert | numeric_literal | tests/integration/test_directory_edge_cases.py | test_directory_stats_functionality | 110 | null | |
meta-llama/synthetic-data-kit | import json
import os
import tempfile
from unittest.mock import MagicMock, patch
import pytest
from typer.testing import CliRunner
from synthetic_data_kit.cli import app
@pytest.mark.functional
def test_system_check_command_vllm(patch_config):
"""Test the system-check command with vLLM provider."""
runner = ... | result.stdout | assert | complex_expr | tests/functional/test_cli.py | test_system_check_command_vllm | 30 | null | |
meta-llama/synthetic-data-kit | from pathlib import Path
import pytest
from synthetic_data_kit.utils import config, text
@pytest.mark.unit
def test_extract_json_from_text():
"""Test extracting JSON from text."""
# Test valid JSON in code block
json_text = """
Some random text before the JSON
```json
{
"question": "W... | ValueError) | pytest.raises | variable | tests/unit/test_utils.py | test_extract_json_from_text | 65 | null | |
meta-llama/synthetic-data-kit | import json
from unittest.mock import MagicMock
import pytest
from synthetic_data_kit.generators.cot_generator import COTGenerator
@pytest.mark.unit
def test_process_document(patch_config):
"""Test processing a document to generate COT examples."""
# Create mock LLM client with config
mock_client = Magic... | result | assert | variable | tests/unit/test_cot_generator.py | test_process_document | 302 | null | |
meta-llama/synthetic-data-kit | import pytest
from synthetic_data_kit.utils import llm_processing
@pytest.mark.unit
def test_parse_qa_pairs():
"""Test parsing QA pairs from LLM output."""
# Test with a JSON array containing multiple QA pairs
json_text = """
Here is the result:
[
{
"question": "What is synthet... | "What is synthetic data?" | assert | string_literal | tests/unit/test_llm_processing.py | test_parse_qa_pairs | 34 | null | |
meta-llama/synthetic-data-kit | import json
import os
import tempfile
from unittest.mock import MagicMock, patch
import pytest
from typer.testing import CliRunner
from synthetic_data_kit.cli import app
@pytest.mark.functional
def test_system_check_command_vllm(patch_config):
"""Test the system-check command with vLLM provider."""
runner = ... | 0 | assert | numeric_literal | tests/functional/test_cli.py | test_system_check_command_vllm | 28 | null | |
meta-llama/synthetic-data-kit | import json
from unittest.mock import MagicMock
import pytest
from synthetic_data_kit.generators.qa_generator import QAGenerator
@pytest.mark.unit
def test_rate_qa_pairs(patch_config):
"""Test rating QA pairs."""
# Create mock LLM client
mock_client = MagicMock()
mock_client.chat_completion.return_va... | 0.5 | assert | numeric_literal | tests/unit/test_qa_generator.py | test_rate_qa_pairs | 136 | null | |
meta-llama/synthetic-data-kit | import json
import os
import tempfile
from unittest.mock import patch
import pytest
from synthetic_data_kit.core import create, curate, save_as
from synthetic_data_kit.models.llm_client import LLMClient
from synthetic_data_kit.utils.llm_processing import parse_qa_pairs
@pytest.mark.unit
def test_llm_client_error_han... | str(excinfo.value) | assert | func_call | tests/unit/test_error_handling.py | test_llm_client_error_handling | 53 | null | |
meta-llama/synthetic-data-kit | import json
from unittest.mock import MagicMock
import pytest
from synthetic_data_kit.generators.cot_generator import COTGenerator
@pytest.mark.unit
def test_enhance_with_cot(patch_config):
"""Test enhancing existing conversations with COT reasoning."""
# Create mock LLM client with config
mock_client = ... | "user" | assert | string_literal | tests/unit/test_cot_generator.py | test_enhance_with_cot | 205 | null | |
meta-llama/synthetic-data-kit | import json
import os
import tempfile
from unittest.mock import MagicMock, patch
import pytest
from synthetic_data_kit.utils.format_converter import (
to_alpaca,
to_chatml,
to_fine_tuning,
to_hf_dataset,
to_jsonl,
)
@pytest.mark.unit
def test_to_fine_tuning():
"""Test conversion to fine-tunin... | "user" | assert | string_literal | tests/unit/test_format_converter.py | test_to_fine_tuning | 161 | null | |
meta-llama/synthetic-data-kit | import json
from unittest.mock import MagicMock
import pytest
from synthetic_data_kit.generators.qa_generator import QAGenerator
@pytest.mark.unit
def test_generate_qa_pairs(patch_config):
"""Test generating QA pairs."""
# Create mock LLM client
mock_client = MagicMock()
mock_client.batch_completion.... | 2 | assert | numeric_literal | tests/unit/test_qa_generator.py | test_generate_qa_pairs | 81 | null | |
meta-llama/synthetic-data-kit | import os
import tempfile
import json
from typing import Dict, List, Tuple, Optional, Any
from pathlib import Path
from unittest.mock import patch
class DirectoryStatsHelper:
@staticmethod
def assert_directory_stats(stats: Dict[str, Any],
expected_total: int,
... | expected_supported | assert | variable | tests/utils/test_helpers.py | assert_directory_stats | DirectoryStatsHelper | 99 | null |
meta-llama/synthetic-data-kit | from pathlib import Path
import pytest
from synthetic_data_kit.utils import config, text
@pytest.mark.unit
def test_get_path_config():
"""Test getting path configuration."""
# Create a test config with proper structure
test_config = {
"paths": {
"output": {"default": "data/output", "g... | "data/input" | assert | string_literal | tests/unit/test_utils.py | test_get_path_config | 149 | null | |
meta-llama/synthetic-data-kit | import os
import tempfile
import json
from unittest.mock import patch, MagicMock
import pytest
@pytest.mark.integration
def test_single_file_ingest_still_works(patch_config):
"""Test that single file ingest processing works unchanged."""
with tempfile.NamedTemporaryFile(mode="w", suffix=".txt", delete=False) ... | output_dir | assert | variable | tests/integration/test_backward_compatibility.py | test_single_file_ingest_still_works | 41 | null | |
meta-llama/synthetic-data-kit | import os
import tempfile
from pathlib import Path
from unittest.mock import patch
import pytest
from synthetic_data_kit.core.context import AppContext
class TestAppContext:
@patch("synthetic_data_kit.core.context.os.makedirs")
@patch("synthetic_data_kit.core.context.load_config")
def test_ensure_data_d... | expected_dir) | assert_* | variable | tests/unit/test_context.py | test_ensure_data_dirs | TestAppContext | 70 | null |
meta-llama/synthetic-data-kit | import os
import tempfile
from unittest.mock import MagicMock, patch
import pytest
from synthetic_data_kit.parsers.docx_parser import DOCXParser
from synthetic_data_kit.parsers.ppt_parser import PPTParser
from synthetic_data_kit.parsers.youtube_parser import YouTubeParser
class TestYouTubeParser:
@patch("builti... | result | assert | variable | tests/unit/test_additional_parsers.py | test_youtube_parse_success | TestYouTubeParser | 221 | null |
meta-llama/synthetic-data-kit | from pathlib import Path
import pytest
from synthetic_data_kit.utils import config, text
@pytest.mark.unit
def test_get_path_config():
"""Test getting path configuration."""
# Create a test config with proper structure
test_config = {
"paths": {
"output": {"default": "data/output", "g... | "data/pdf" | assert | string_literal | tests/unit/test_utils.py | test_get_path_config | 152 | null | |
meta-llama/synthetic-data-kit | import os
import tempfile
from pathlib import Path
from unittest.mock import patch
import pytest
from synthetic_data_kit.core.context import AppContext
class TestAppContext:
def test_app_context_initialization_default_config(self):
"""Test AppContext initialization with default config path"""
wi... | "/fake/default/path" | assert | string_literal | tests/unit/test_context.py | test_app_context_initialization_default_config | TestAppContext | 25 | null |
meta-llama/synthetic-data-kit | import json
import os
import tempfile
from unittest.mock import MagicMock, patch
import pytest
from typer.testing import CliRunner
from synthetic_data_kit.cli import app
@pytest.mark.functional
def test_ingest_command(patch_config):
"""Test the ingest command with a text file."""
runner = CliRunner()
wi... | input_path | assert | variable | tests/functional/test_cli.py | test_ingest_command | 78 | null | |
meta-llama/synthetic-data-kit | import json
from unittest.mock import MagicMock
import pytest
from synthetic_data_kit.generators.cot_generator import COTGenerator
@pytest.mark.unit
def test_cot_generator_initialization(patch_config):
"""Test COT generator initialization."""
# Create mock LLM client
mock_client = MagicMock()
# Init... | mock_client | assert | variable | tests/unit/test_cot_generator.py | test_cot_generator_initialization | 21 | null | |
meta-llama/synthetic-data-kit | import os
import tempfile
from unittest.mock import MagicMock, patch
import pytest
from synthetic_data_kit.parsers.html_parser import HTMLParser
from synthetic_data_kit.parsers.pdf_parser import PDFParser
from synthetic_data_kit.parsers.txt_parser import TXTParser
@pytest.mark.unit
def test_pdf_parser():
"""Test... | [{"text": "This is sample PDF content for testing."}] | assert | collection | tests/unit/test_parsers.py | test_pdf_parser | 131 | null | |
meta-llama/synthetic-data-kit | import json
import os
import tempfile
from unittest.mock import patch
import pytest
from synthetic_data_kit.core import create, curate, save_as
from synthetic_data_kit.models.llm_client import LLMClient
from synthetic_data_kit.utils.llm_processing import parse_qa_pairs
@pytest.mark.unit
def test_save_as_unknown_form... | ValueError) | pytest.raises | variable | tests/unit/test_error_handling.py | test_save_as_unknown_format | 78 | null | |
meta-llama/synthetic-data-kit | from pathlib import Path
import pytest
from synthetic_data_kit.utils import config, text
@pytest.mark.unit
def test_extract_json_list_from_text():
"""Test extracting JSON list from text."""
json_text = """
Some random text before the JSON
```json
[
{
"question": "What is synth... | "Why use synthetic data?" | assert | string_literal | tests/unit/test_utils.py | test_extract_json_list_from_text | 94 | null | |
meta-llama/synthetic-data-kit | import os
import tempfile
import json
from unittest.mock import patch, MagicMock
import pytest
from synthetic_data_kit.utils.directory_processor import (
process_directory_ingest,
process_directory_save_as,
get_directory_stats,
INGEST_EXTENSIONS,
SAVE_AS_EXTENSIONS
)
@pytest.mark.integration
def ... | 3 | assert | numeric_literal | tests/integration/test_directory_edge_cases.py | test_directory_stats_functionality | 108 | null | |
meta-llama/synthetic-data-kit | import json
import os
import tempfile
from unittest.mock import MagicMock, patch
import pytest
from synthetic_data_kit.utils.format_converter import (
to_alpaca,
to_chatml,
to_fine_tuning,
to_hf_dataset,
to_jsonl,
)
@pytest.mark.unit
def test_to_alpaca():
"""Test conversion to Alpaca format."... | "" | assert | string_literal | tests/unit/test_format_converter.py | test_to_alpaca | 111 | null | |
meta-llama/synthetic-data-kit | import os
import tempfile
from unittest.mock import MagicMock, patch
import pytest
from synthetic_data_kit.parsers.docx_parser import DOCXParser
from synthetic_data_kit.parsers.ppt_parser import PPTParser
from synthetic_data_kit.parsers.youtube_parser import YouTubeParser
class TestDOCXParser:
@patch("builtins.... | [{"text": expected}] | assert | collection | tests/unit/test_additional_parsers.py | test_docx_parse_success | TestDOCXParser | 64 | null |
meta-llama/synthetic-data-kit | import json
import os
import tempfile
from unittest.mock import MagicMock, patch
import pytest
from synthetic_data_kit.utils.format_converter import (
to_alpaca,
to_chatml,
to_fine_tuning,
to_hf_dataset,
to_jsonl,
)
@pytest.mark.unit
def test_to_alpaca():
"""Test conversion to Alpaca format."... | data[0] | assert | complex_expr | tests/unit/test_format_converter.py | test_to_alpaca | 105 | null | |
meta-llama/synthetic-data-kit | import json
import os
import tempfile
from unittest.mock import patch
import pytest
from synthetic_data_kit.core import create, curate, save_as
from synthetic_data_kit.models.llm_client import LLMClient
from synthetic_data_kit.utils.llm_processing import parse_qa_pairs
@pytest.mark.unit
def test_llm_client_error_han... | Exception) | pytest.raises | variable | tests/unit/test_error_handling.py | test_llm_client_error_handling | 49 | null | |
meta-llama/synthetic-data-kit | import json
import os
import tempfile
from unittest.mock import patch
import pytest
from synthetic_data_kit.core import save_as
@pytest.mark.integration
def test_convert_format():
"""Test converting QA pairs to different formats."""
# Create sample QA pairs
qa_pairs = [
{
"question": ... | data[0] | assert | complex_expr | tests/integration/test_save_as_flow.py | test_convert_format | 78 | null | |
meta-llama/synthetic-data-kit | import json
import os
import tempfile
from unittest.mock import MagicMock, patch
import pytest
from synthetic_data_kit.utils.format_converter import (
to_alpaca,
to_chatml,
to_fine_tuning,
to_hf_dataset,
to_jsonl,
)
@pytest.mark.unit
def test_to_hf_dataset():
"""Test conversion to Hugging Fac... | call_args | assert | variable | tests/unit/test_format_converter.py | test_to_hf_dataset | 262 | null | |
meta-llama/synthetic-data-kit | import os
import tempfile
import json
from unittest.mock import patch, MagicMock
import pytest
from synthetic_data_kit.utils.directory_processor import (
process_directory_ingest,
process_directory_save_as,
get_directory_stats,
INGEST_EXTENSIONS,
SAVE_AS_EXTENSIONS
)
@pytest.mark.integration
def ... | stats | assert | variable | tests/integration/test_directory_edge_cases.py | test_nonexistent_directory_error | 131 | null | |
meta-llama/synthetic-data-kit | import os
import tempfile
from unittest.mock import MagicMock, patch
import pytest
from synthetic_data_kit.parsers.html_parser import HTMLParser
from synthetic_data_kit.parsers.pdf_parser import PDFParser
from synthetic_data_kit.parsers.txt_parser import TXTParser
@pytest.mark.unit
def test_pdf_parser():
"""Test... | file_path) | assert_* | variable | tests/unit/test_parsers.py | test_pdf_parser | 128 | null | |
meta-llama/synthetic-data-kit | import os
import tempfile
import json
from unittest.mock import patch
import pytest
@pytest.mark.functional
def test_create_preview_mode(patch_config):
"""Test create command with --preview flag."""
temp_dir = tempfile.mkdtemp()
try:
# Create test .txt files for create command
txt_fil... | 0 | assert | numeric_literal | tests/functional/test_preview_mode.py | test_create_preview_mode | 73 | null | |
meta-llama/synthetic-data-kit | import json
import os
import tempfile
from unittest.mock import MagicMock, patch
import pytest
from synthetic_data_kit.utils.format_converter import (
to_alpaca,
to_chatml,
to_fine_tuning,
to_hf_dataset,
to_jsonl,
)
@pytest.mark.unit
def test_to_fine_tuning():
"""Test conversion to fine-tunin... | "system" | assert | string_literal | tests/unit/test_format_converter.py | test_to_fine_tuning | 160 | null | |
meta-llama/synthetic-data-kit | import os
import tempfile
from unittest.mock import MagicMock, patch
import pytest
from synthetic_data_kit.parsers.docx_parser import DOCXParser
from synthetic_data_kit.parsers.ppt_parser import PPTParser
from synthetic_data_kit.parsers.youtube_parser import YouTubeParser
class TestDOCXParser:
@patch("builtins.... | "/fake/path.docx") | assert_* | string_literal | tests/unit/test_additional_parsers.py | test_docx_parse_success | TestDOCXParser | 68 | null |
meta-llama/synthetic-data-kit | import json
from unittest.mock import MagicMock
import pytest
from synthetic_data_kit.generators.qa_generator import QAGenerator
@pytest.mark.unit
def test_rate_qa_pairs(patch_config):
"""Test rating QA pairs."""
# Create mock LLM client
mock_client = MagicMock()
mock_client.chat_completion.return_va... | 8 | assert | numeric_literal | tests/unit/test_qa_generator.py | test_rate_qa_pairs | 131 | null | |
meta-llama/synthetic-data-kit | import os
import shutil
import subprocess
import pytest
import requests
import lance
PDF_URL = "https://www.adobe.com/support/products/enterprise/knowledgecenter/media/c4611_sample_explain.pdf"
PDF_FILENAME = "sample_multimodal.pdf"
OUTPUT_DIR = "test_output"
def setup_module():
"""Download the test PDF and creat... | 0 | assert | numeric_literal | tests/functional/test_multimodal.py | test_ingest_pdf_default | 47 | null | |
meta-llama/synthetic-data-kit | from pathlib import Path
import pytest
from synthetic_data_kit.utils import config, text
@pytest.mark.unit
def test_extract_json_from_text():
"""Test extracting JSON from text."""
# Test valid JSON in code block
json_text = """
Some random text before the JSON
```json
{
"question": "W... | "Synthetic data is artificially generated data." | assert | string_literal | tests/unit/test_utils.py | test_extract_json_from_text | 57 | null | |
meta-llama/synthetic-data-kit | import json
from unittest.mock import MagicMock
import pytest
from synthetic_data_kit.generators.qa_generator import QAGenerator
@pytest.mark.unit
def test_generate_qa_pairs(patch_config):
"""Test generating QA pairs."""
# Create mock LLM client
mock_client = MagicMock()
mock_client.batch_completion.... | "Why use synthetic data?" | assert | string_literal | tests/unit/test_qa_generator.py | test_generate_qa_pairs | 83 | null | |
meta-llama/synthetic-data-kit | import pytest
from synthetic_data_kit.utils import llm_processing
@pytest.mark.unit
def test_convert_to_conversation_format():
"""Test converting QA pairs to conversation format."""
qa_pairs = [
{
"question": "What is synthetic data?",
"answer": "Synthetic data is artificially ... | "user" | assert | string_literal | tests/unit/test_llm_processing.py | test_convert_to_conversation_format | 80 | null | |
meta-llama/synthetic-data-kit | from pathlib import Path
import pytest
from synthetic_data_kit.utils import config, text
@pytest.mark.unit
def test_load_config(tmpdir):
"""Test loading config from file."""
# Create a temporary config file
config_path = Path(tmpdir) / "test_config.yaml"
with open(config_path, "w") as f:
f.w... | "test-provider" | assert | string_literal | tests/unit/test_utils.py | test_load_config | 112 | null | |
meta-llama/synthetic-data-kit | import os
import tempfile
from unittest.mock import MagicMock, patch
import pytest
from synthetic_data_kit.core import create
@pytest.mark.integration
def test_process_directory(patch_config, test_env):
"""Test processing a directory to generate QA pairs."""
# Create a temporary directory with test files
... | len(file_paths) | assert | func_call | tests/integration/test_create_flow.py | test_process_directory | 151 | null | |
meta-llama/synthetic-data-kit | import os
import tempfile
from unittest.mock import MagicMock, patch
import pytest
from synthetic_data_kit.core import create
@pytest.mark.integration
def test_process_directory(patch_config, test_env):
"""Test processing a directory to generate QA pairs."""
# Create a temporary directory with test files
... | results | assert | variable | tests/integration/test_create_flow.py | test_process_directory | 155 | null | |
meta-llama/synthetic-data-kit | import json
from unittest.mock import MagicMock
import pytest
from synthetic_data_kit.generators.qa_generator import QAGenerator
@pytest.mark.unit
def test_rate_qa_pairs(patch_config):
"""Test rating QA pairs."""
# Create mock LLM client
mock_client = MagicMock()
mock_client.chat_completion.return_va... | 1 | assert | numeric_literal | tests/unit/test_qa_generator.py | test_rate_qa_pairs | 129 | null | |
meta-llama/synthetic-data-kit | import json
import os
import tempfile
from unittest.mock import MagicMock, patch
import pytest
from synthetic_data_kit.utils.format_converter import (
to_alpaca,
to_chatml,
to_fine_tuning,
to_hf_dataset,
to_jsonl,
)
@pytest.mark.unit
def test_to_chatml():
"""Test conversion to ChatML format."... | line1_data | assert | variable | tests/unit/test_format_converter.py | test_to_chatml | 211 | null | |
offu/WeRoBot | from werobot.messages.entries import get_value, StringEntry, FloatEntry, IntEntry
from werobot.utils import to_text
def test_get_value():
instance = FakeIntance()
instance.b = 6
instance.a = {'c': 'd'}
assert get_value(instance, 'd', 'default') == | 'default' | assert | string_literal | tests/messages/test_entries.py | test_get_value | 79 | null | |
offu/WeRoBot | import os
import random
import sys
import time
import pytest
import tornado
import webtest
from tornado.testing import AsyncHTTPSTestCase
from webtest.app import AppError
from werobot.parser import parse_xml, process_message
from werobot.utils import generate_token, get_signature
def wsgi_tester():
def tester(ap... | 200 | assert | numeric_literal | tests/test_contrib.py | test_django | 117 | null | |
offu/WeRoBot | import hashlib
import time
import os
import pytest
from werobot import WeRoBot
from werobot.utils import generate_token, to_text
def _make_xml(content):
return """
<xml>
<ToUserName><![CDATA[toUser]]></ToUserName>
<FromUserName><![CDATA[fromUser]]></FromUserName>
<CreateTime>134883... | [(link_handler, 0)] | assert | collection | tests/test_robot.py | test_register_handlers | 95 | null | |
offu/WeRoBot | import os
from werobot import WeRoBot
from werobot.config import Config
from werobot.utils import generate_token
basedir = os.path.dirname(os.path.abspath(__file__))
TOKEN = "123"
def test_from_pyfile():
config = Config()
assert "TOKEN" not in | config | assert | variable | tests/test_config.py | test_from_pyfile | 14 | null | |
offu/WeRoBot | import time
import pytest
from werobot.parser import parse_user_msg
from werobot.replies import WeChatReply, TextReply, ImageReply, MusicReply
from werobot.replies import VoiceReply, VideoReply
from werobot.replies import Article, ArticlesReply
from werobot.replies import TransferCustomerServiceReply, SuccessReply
fro... | 'u2' | assert | string_literal | tests/test_replies.py | test_music_reply_process_args | 202 | null | |
offu/WeRoBot | import re
from werobot.utils import generate_token, check_token, to_text, to_binary
from werobot.utils import pay_sign_dict, make_error_page, is_regex
def test_token_generator():
assert not check_token('AA C')
assert check_token(generate_token())
assert 3 <= | len(generate_token()) | assert | func_call | tests/test_utils.py | test_token_generator | 12 | null | |
offu/WeRoBot | from werobot import WeRoBot
from werobot.parser import parse_user_msg
from werobot.replies import TextReply
import os
werobot = WeRoBot(SESSION_STORAGE=False)
def teardown_module(module):
try:
os.remove(os.path.abspath("werobot_session"))
except OSError:
pass
def test_image():
@werobot.im... | u'图片喵' | assert | complex_expr | tests/test_handler.py | test_image | 771 | null | |
offu/WeRoBot | import hashlib
import time
import os
import pytest
from werobot import WeRoBot
from werobot.utils import generate_token, to_text
def _make_xml(content):
return """
<xml>
<ToUserName><![CDATA[toUser]]></ToUserName>
<FromUserName><![CDATA[fromUser]]></FromUserName>
<CreateTime>134883... | 2 | assert | numeric_literal | tests/test_robot.py | test_register_handlers | 125 | null | |
offu/WeRoBot | from werobot import WeRoBot
from werobot.parser import parse_user_msg
from werobot.replies import TextReply
import os
werobot = WeRoBot(SESSION_STORAGE=False)
def teardown_module(module):
try:
os.remove(os.path.abspath("werobot_session"))
except OSError:
pass
def test_user_scan_product():
... | u'打扰了' | assert | complex_expr | tests/test_handler.py | test_user_scan_product | 930 | null | |
offu/WeRoBot | from werobot.messages.entries import get_value, StringEntry, FloatEntry, IntEntry
from werobot.utils import to_text
def test_string_entry():
assert isinstance(t.test_string, str)
assert t.test_string == "hello"
assert isinstance(t.test_int_to_string, str)
assert t.test_int_to_string == | "123" | assert | string_literal | tests/messages/test_entries.py | test_string_entry | 63 | null | |
offu/WeRoBot | from werobot import WeRoBot
from werobot.parser import parse_user_msg
from werobot.replies import TextReply
import os
werobot = WeRoBot(SESSION_STORAGE=False)
def teardown_module(module):
try:
os.remove(os.path.abspath("werobot_session"))
except OSError:
pass
def test_link():
@werobot.lin... | u'链接喵' | assert | complex_expr | tests/test_handler.py | test_link | 824 | null | |
offu/WeRoBot | import time
import pytest
from werobot.parser import parse_user_msg
from werobot.replies import WeChatReply, TextReply, ImageReply, MusicReply
from werobot.replies import VoiceReply, VideoReply
from werobot.replies import Article, ArticlesReply
from werobot.replies import TransferCustomerServiceReply, SuccessReply
fro... | "success" | assert | string_literal | tests/test_replies.py | test_success_reply | 282 | null | |
offu/WeRoBot | import os
import mongomock
import mockredis
import pytest
import sqlite3
import werobot
import werobot.testing
import werobot.utils
from werobot.session import SessionStorage
from werobot.session import filestorage, mongodbstorage, redisstorage, saekvstorage
from werobot.session import sqlitestorage
from werobot.sessi... | {} | assert | collection | tests/test_session.py | test_storage | 152 | null | |
offu/WeRoBot | import re
from werobot.utils import generate_token, check_token, to_text, to_binary
from werobot.utils import pay_sign_dict, make_error_page, is_regex
def test_to_text():
assert to_text(6) == str(6)
assert to_text(b"aa") == | "aa" | assert | string_literal | tests/test_utils.py | test_to_text | 17 | null | |
offu/WeRoBot | import time
import pytest
from werobot.parser import parse_user_msg
from werobot.replies import WeChatReply, TextReply, ImageReply, MusicReply
from werobot.replies import VoiceReply, VideoReply
from werobot.replies import Article, ArticlesReply
from werobot.replies import TransferCustomerServiceReply, SuccessReply
fro... | "title" | assert | string_literal | tests/test_replies.py | test_process_music_function_reply | 299 | null | |
offu/WeRoBot | import hashlib
import time
import os
import pytest
from werobot import WeRoBot
from werobot.utils import generate_token, to_text
def _make_xml(content):
return """
<xml>
<ToUserName><![CDATA[toUser]]></ToUserName>
<FromUserName><![CDATA[fromUser]]></FromUserName>
<CreateTime>134883... | None | assert | none_literal | tests/test_robot.py | test_add_filter | 247 | null | |
offu/WeRoBot | import time
import pytest
from werobot.parser import parse_user_msg
from werobot.replies import WeChatReply, TextReply, ImageReply, MusicReply
from werobot.replies import VoiceReply, VideoReply
from werobot.replies import Article, ArticlesReply
from werobot.replies import TransferCustomerServiceReply, SuccessReply
fro... | "tt1" | assert | string_literal | tests/test_replies.py | test_process_articles_function_reply | 319 | null | |
offu/WeRoBot | import os
import random
import sys
import time
import pytest
import tornado
import webtest
from tornado.testing import AsyncHTTPSTestCase
from webtest.app import AppError
from werobot.parser import parse_xml, process_message
from werobot.utils import generate_token, get_signature
def wsgi_tester():
def tester(ap... | u'喵' | assert | complex_expr | tests/test_contrib.py | test_django | 135 | null | |
offu/WeRoBot | import time
import pytest
from werobot.parser import parse_user_msg
from werobot.replies import WeChatReply, TextReply, ImageReply, MusicReply
from werobot.replies import VoiceReply, VideoReply
from werobot.replies import Article, ArticlesReply
from werobot.replies import TransferCustomerServiceReply, SuccessReply
fro... | "ds1" | assert | string_literal | tests/test_replies.py | test_process_articles_function_reply | 320 | null | |
offu/WeRoBot | import hashlib
import time
import os
import pytest
from werobot import WeRoBot
from werobot.utils import generate_token, to_text
def _make_xml(content):
return """
<xml>
<ToUserName><![CDATA[toUser]]></ToUserName>
<FromUserName><![CDATA[fromUser]]></FromUserName>
<CreateTime>134883... | "test" | assert | string_literal | tests/test_robot.py | test_add_filter | 245 | null | |
offu/WeRoBot | from werobot.parser import parse_user_msg
def test_update_member_card_event():
message = parse_user_msg(
"""
<xml>
<ToUserName><![CDATA[gh_9e1765b5568e]]></ToUserName>
<FromUserName><![CDATA[ojZ8YtyVyr30HheH3CM73y7h4jJE]]></FromUserName>
<CreateTime>1445507140</C... | 3 | assert | numeric_literal | tests/test_parser.py | test_update_member_card_event | 646 | null | |
offu/WeRoBot | from werobot.messages.entries import get_value, StringEntry, FloatEntry, IntEntry
from werobot.utils import to_text
def test_int_entry():
assert isinstance(t.test_int, int)
assert t.test_int == 123
assert isinstance(t.test_string_to_int, int)
assert t.test_string_to_int == 123
assert isinstance(t.t... | None | assert | none_literal | tests/messages/test_entries.py | test_int_entry | 48 | null | |
offu/WeRoBot | import time
import pytest
from werobot.parser import parse_user_msg
from werobot.replies import WeChatReply, TextReply, ImageReply, MusicReply
from werobot.replies import VoiceReply, VideoReply
from werobot.replies import Article, ArticlesReply
from werobot.replies import TransferCustomerServiceReply, SuccessReply
fro... | "desc" | assert | string_literal | tests/test_replies.py | test_process_music_function_reply | 300 | null | |
offu/WeRoBot | from werobot.crypto import PrpCrypto, MessageCrypt
from werobot.utils import generate_token, to_binary, to_text
from werobot.parser import parse_xml
import time
def test_message_crypt():
encoding_aes_key = generate_token(32) + generate_token(11)
token = generate_token()
timestamp = to_text(int(time.time())... | to_binary('hello') | assert | func_call | tests/test_crypto.py | test_message_crypt | 39 | null | |
offu/WeRoBot | import re
from werobot.utils import generate_token, check_token, to_text, to_binary
from werobot.utils import pay_sign_dict, make_error_page, is_regex
def test_to_binary():
assert to_binary(6) == bytes(6)
assert to_binary(b"aa") == b"aa"
assert to_binary("cc") == b"cc"
assert to_binary(u"喵") == b" | b"\xe5\x96\xb5" | assert | string_literal | tests/test_utils.py | test_to_binary | 27 | null | |
offu/WeRoBot | from werobot.messages.entries import get_value, StringEntry, FloatEntry, IntEntry
from werobot.utils import to_text
def test_get_value():
instance = FakeIntance()
instance.b = 6
instance.a = {'c': 'd'}
assert get_value(instance, 'd', 'default') == 'default'
assert get_value(instance, 'b', 'default... | 6 | assert | numeric_literal | tests/messages/test_entries.py | test_get_value | 80 | null | |
offu/WeRoBot | import re
from werobot.utils import generate_token, check_token, to_text, to_binary
from werobot.utils import pay_sign_dict, make_error_page, is_regex
def test_to_binary():
assert to_binary(6) == bytes(6)
assert to_binary(b"aa") == b"aa"
assert to_binary("cc") == | b"cc" | assert | string_literal | tests/test_utils.py | test_to_binary | 26 | null | |
offu/WeRoBot | import re
from werobot.utils import generate_token, check_token, to_text, to_binary
from werobot.utils import pay_sign_dict, make_error_page, is_regex
def test_to_text():
assert to_text(6) == str(6)
assert to_text(b"aa") == "aa"
assert to_text("cc") == | "cc" | assert | string_literal | tests/test_utils.py | test_to_text | 18 | null | |
offu/WeRoBot | import re
from werobot.utils import generate_token, check_token, to_text, to_binary
from werobot.utils import pay_sign_dict, make_error_page, is_regex
def test_to_text():
assert to_text(6) == | str(6) | assert | func_call | tests/test_utils.py | test_to_text | 16 | null | |
offu/WeRoBot | from werobot.parser import parse_user_msg
def test_location_message():
message = parse_user_msg(
"""
<xml>
<ToUserName><![CDATA[toUser]]></ToUserName>
<FromUserName><![CDATA[fromUser]]></FromUserName>
<CreateTime>1351776360</CreateTime>
<MsgType><![CDATA[location]]></Msg... | 20 | assert | numeric_literal | tests/test_parser.py | test_location_message | 73 | null | |
offu/WeRoBot | import re
from werobot.utils import generate_token, check_token, to_text, to_binary
from werobot.utils import pay_sign_dict, make_error_page, is_regex
def test_to_binary():
assert to_binary(6) == bytes(6)
assert to_binary(b"aa") == | b"aa" | assert | string_literal | tests/test_utils.py | test_to_binary | 25 | null | |
offu/WeRoBot | import os
import responses
import json
import pytest
import requests
import multipart
import urllib.parse
from io import BytesIO
from werobot import WeRoBot
from werobot.config import Config
from werobot.client import Client, check_error, ClientException
from werobot.utils import cached_property
BASE_DIR = os.path.di... | "123" | assert | string_literal | tests/test_client.py | test_id_and_secret | TestClientBaseClass | 67 | null |
offu/WeRoBot | import re
from werobot.utils import generate_token, check_token, to_text, to_binary
from werobot.utils import pay_sign_dict, make_error_page, is_regex
def test_pay_sign_dict():
appid = {"id": "nothing"}
key = "test_key"
pay_sign = pay_sign_dict(appid, key)
assert "timestamp" in pay_sign[0]
asser... | u"SHA1" | assert | complex_expr | tests/test_utils.py | test_pay_sign_dict | 41 | null | |
offu/WeRoBot | from werobot.messages.entries import get_value, StringEntry, FloatEntry, IntEntry
from werobot.utils import to_text
def test_int_entry():
assert isinstance(t.test_int, int)
assert t.test_int == | 123 | assert | numeric_literal | tests/messages/test_entries.py | test_int_entry | 43 | null | |
offu/WeRoBot | import os
from werobot import WeRoBot
from werobot.config import Config
from werobot.utils import generate_token
basedir = os.path.dirname(os.path.abspath(__file__))
TOKEN = "123"
def test_from_object():
config = Config()
config.from_pyfile(os.path.join(basedir, "test_config.py"))
class ConfigObject:
... | "456" | assert | string_literal | tests/test_config.py | test_from_object | 27 | null | |
offu/WeRoBot | import os
import responses
import json
import pytest
import requests
import multipart
import urllib.parse
from io import BytesIO
from werobot import WeRoBot
from werobot.config import Config
from werobot.client import Client, check_error, ClientException
from werobot.utils import cached_property
BASE_DIR = os.path.di... | r | assert | variable | tests/test_client.py | test_get_status | TestClientMass | 1,999 | null |
offu/WeRoBot | from werobot import WeRoBot
from werobot.parser import parse_user_msg
from werobot.replies import TextReply
import os
werobot = WeRoBot(SESSION_STORAGE=False)
def teardown_module(module):
try:
os.remove(os.path.abspath("werobot_session"))
except OSError:
pass
def test_user_pay_from_pay_cell_h... | u'冲动消费' | assert | complex_expr | tests/test_handler.py | test_user_pay_from_pay_cell_handler | 512 | null | |
offu/WeRoBot | import re
from werobot.utils import generate_token, check_token, to_text, to_binary
from werobot.utils import pay_sign_dict, make_error_page, is_regex
def test_pay_sign_dict():
appid = {"id": "nothing"}
key = "test_key"
pay_sign = pay_sign_dict(appid, key)
assert "timestamp" in | pay_sign[0] | assert | complex_expr | tests/test_utils.py | test_pay_sign_dict | 37 | null | |
offu/WeRoBot | import time
import pytest
from werobot.parser import parse_user_msg
from werobot.replies import WeChatReply, TextReply, ImageReply, MusicReply
from werobot.replies import VoiceReply, VideoReply
from werobot.replies import Article, ArticlesReply
from werobot.replies import TransferCustomerServiceReply, SuccessReply
fro... | '' | assert | string_literal | tests/test_replies.py | test_video_reply_process_args | 154 | null | |
offu/WeRoBot | import os
import random
import sys
import time
import pytest
import tornado
import webtest
from tornado.testing import AsyncHTTPSTestCase
from webtest.app import AppError
from werobot.parser import parse_xml, process_message
from werobot.utils import generate_token, get_signature
def wsgi_tester():
def tester(ap... | 405 | assert | numeric_literal | tests/test_contrib.py | test_django | 145 | null | |
offu/WeRoBot | import os
import random
import sys
import time
import pytest
import tornado
import webtest
from tornado.testing import AsyncHTTPSTestCase
from webtest.app import AppError
from werobot.parser import parse_xml, process_message
from werobot.utils import generate_token, get_signature
def wsgi_tester():
def tester(ap... | 403 | assert | numeric_literal | tests/test_contrib.py | test_django | 134 | null | |
offu/WeRoBot | from werobot import WeRoBot
from werobot.parser import parse_user_msg
from werobot.replies import TextReply
import os
werobot = WeRoBot(SESSION_STORAGE=False)
def teardown_module(module):
try:
os.remove(os.path.abspath("werobot_session"))
except OSError:
pass
def test_subscribe_handler():
... | u'关注' | assert | complex_expr | tests/test_handler.py | test_subscribe_handler | 38 | null | |
offu/WeRoBot | import os
import responses
import json
import pytest
import requests
import multipart
import urllib.parse
from io import BytesIO
from werobot import WeRoBot
from werobot.config import Config
from werobot.client import Client, check_error, ClientException
from werobot.utils import cached_property
BASE_DIR = os.path.di... | body | assert | variable | tests/test_client.py | send_all_openid_callback | TestClientMass | 1,803 | null |
offu/WeRoBot | import time
import pytest
from werobot.parser import parse_user_msg
from werobot.replies import WeChatReply, TextReply, ImageReply, MusicReply
from werobot.replies import VoiceReply, VideoReply
from werobot.replies import Article, ArticlesReply
from werobot.replies import TransferCustomerServiceReply, SuccessReply
fro... | "test" | assert | string_literal | tests/test_replies.py | test_process_text_function_reply | 293 | null | |
offu/WeRoBot | import time
import pytest
from werobot.parser import parse_user_msg
from werobot.replies import WeChatReply, TextReply, ImageReply, MusicReply
from werobot.replies import VoiceReply, VideoReply
from werobot.replies import Article, ArticlesReply
from werobot.replies import TransferCustomerServiceReply, SuccessReply
fro... | 'u1' | assert | string_literal | tests/test_replies.py | test_music_reply_process_args | 192 | null | |
offu/WeRoBot | import time
import pytest
from werobot.parser import parse_user_msg
from werobot.replies import WeChatReply, TextReply, ImageReply, MusicReply
from werobot.replies import VoiceReply, VideoReply
from werobot.replies import Article, ArticlesReply
from werobot.replies import TransferCustomerServiceReply, SuccessReply
fro... | "img" | assert | string_literal | tests/test_replies.py | test_process_articles_function_reply | 321 | null | |
offu/WeRoBot | from werobot.messages.entries import get_value, StringEntry, FloatEntry, IntEntry
from werobot.utils import to_text
def test_string_entry():
assert isinstance(t.test_string, str)
assert t.test_string == "hello"
assert isinstance(t.test_int_to_string, str)
assert t.test_int_to_string == "123"
assert... | to_text("喵") | assert | func_call | tests/messages/test_entries.py | test_string_entry | 67 | null | |
offu/WeRoBot | from werobot import WeRoBot
from werobot.parser import parse_user_msg
from werobot.replies import TextReply
import os
werobot = WeRoBot(SESSION_STORAGE=False)
def teardown_module(module):
try:
os.remove(os.path.abspath("werobot_session"))
except OSError:
pass
def test_unsubscribe_handler():
... | u'取消关注' | assert | complex_expr | tests/test_handler.py | test_unsubscribe_handler | 61 | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.