text stringlengths 14 100k | source stringclasses 1
value | repo stringclasses 810
values | language stringclasses 13
values |
|---|---|---|---|
<|fim_prefix|>import pickle
from pathlib import Path
from dataclasses import dataclass, field
import anyio
from anyio import Path as AsyncPath
from scrapling.core.utils import log
from scrapling.core._types import Set, List, Optional, TYPE_CHECKING
if TYPE_CHECKING:
from scrapling.spiders.request import Request
... | fim | D4Vinci/Scrapling | python |
<|fim_suffix|>t_response_bytes(request.domain, len(response.body))
self.stats.increment_status(response.status)
except Exception as e:
self.stats.failed_requests_count += 1
await self.spider.on_error(request, e)
return
if self._cache_... | fim | D4Vinci/Scrapling | python |
<|fim_suffix|> return False
if self.deny and any(p.search(url) for p in self.deny):
return False
if self.allow_domains or self.deny_domains:
host = (urlsplit(url).hostname or "").lower()
if self.allow_domains and not any(host == d or host.endswith("." + d) ... | fim | D4Vinci/Scrapling | python |
<|fim_prefix|>import hashlib
from io import BytesIO
from functools import cached_property
from urllib.parse import urlparse, urlencode
import orjson
from w3lib.url import canonicalize_url
from scrapling.engines.toolbelt.custom import Response
from scrapling.core._types import Any, AsyncGenerator, Callable, Dict, Opti... | fim | D4Vinci/Scrapling | python |
<|fim_suffix|> def to_dict(self) -> dict[str, Any]:
return {
"items_scraped": self.items_scraped,
"items_dropped": self.items_dropped,
"elapsed_seconds": round(self.elapsed_seconds, 2),
"download_delay": round(self.download_delay, 2),
"concurrent_req... | fim | D4Vinci/Scrapling | python |
from urllib.parse import urlparse
from anyio import create_task_group
from protego import Protego
from scrapling.core._types import Dict, Optional, Callable, Awaitable
from scrapling.core.utils import log
class RobotsTxtManager:
"""Manages fetching, parsing, and caching of robots.txt files."""
def __init__... | fim | D4Vinci/Scrapling | python |
<|fim_suffix|>"Restore scheduler state from checkpoint data.
:param data: CheckpointData containing requests and seen set
"""
self._seen = data.seen.copy()
# Restore pending requests in order (they're already sorted by priority)
for request in data.requests:
counter... | fim | D4Vinci/Scrapling | python |
<|fim_suffix|>y_sessions.remove(session_id)
if session and self._default_session_id == session_id:
self._default_session_id = next(iter(self._sessions), None)
return session
@property
def default_session_id(self) -> str:
if self._default_session_id is None:
rai... | fim | D4Vinci/Scrapling | python |
<|fim_suffix|> for handler in self.logger.handlers:
if isinstance(handler, logging.FileHandler):
handler.close()
@property
def stats(self) -> CrawlStats:
"""Access current crawl stats (works during streaming)."""
if self._engine:
... | fim | D4Vinci/Scrapling | python |
<|fim_prefix|>from .crawler import CrawlSpider, CrawlR<|fim_suffix|>_ = [
"CrawlSpider",
"CrawlRule",
"SitemapSpider",
]
<|fim_middle|>ule
from .sitemap import SitemapSpider
__all_<|endoftext|> | fim | D4Vinci/Scrapling | python |
<|fim_suffix|>rride to define link-following rules."""
return []
async def parse(self, response: "Response") -> AsyncGenerator[Union[Dict[str, Any], Request, None], None]:
for rule in self.rules():
for url in rule.link_extractor.extract(response):
req = response.follow(u... | fim | D4Vinci/Scrapling | python |
<|fim_prefix|>"""Sitemap template spider."""
from dataclasses import dataclass, field
from gzip import GzipFile
from io import BytesIO
from urllib.parse import urlsplit
from lxml import etree
from protego import Protego
from scrapling.core._types import (
TYPE_CHECKING,
Any,
AsyncGenerator<|fim_suffix|> ... | fim | D4Vinci/Scrapling | python |
"""Package for test project."""
<|endoftext|> | fim | D4Vinci/Scrapling | python |
<|fim_prefix|>import base64
import struct
from contextlib import contextmanager
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
from threading import Thread
import pytest
import pytest_httpbin
from mcp.types import ImageContent, TextContent
from scrapling.core.ai import (
ScraplingMCPServer,
... | fim | D4Vinci/Scrapling | python |
<|fim_prefix|>import pytest
from click.testing import CliRunner
from unittest.mock import patch, MagicMock
import pytest_httpbin
from scrapling.parser import Selector
from scrapling import __version__
from scrapling.cli import (
main, shell, mcp, get, post, put, delete, fetch, stealthy_fetch
)
@pytest_httpbin.us... | fim | D4Vinci/Scrapling | python |
<|fim_suffix|>v>
</body>
</html>
"""
def test_extract_markdown(self, sample_html):
"""Test extracting content as Markdown"""
page = Selector(sample_html)
content = list(Convertor._extract_content(page, "markdown"))
assert len(content) > 0
assert ... | fim | D4Vinci/Scrapling | python |
<|fim_suffix|>hod == "POST"
assert request.data == '{"key": "value"}'
assert request.json_data == {"key": "value"}
assert request.proxy == "http://proxy:8080"
assert request.follow_redirects is False
def test_request_field_access(self):
"""Test accessing Request fields""... | fim | D4Vinci/Scrapling | python |
<|fim_prefix|>import tempfile
import os
import threading
from lxml.html import fromstring
from scrapling.core.storage import SQLiteStorageSystem, StorageSystemMixin
from scrapling.core.utils import _StorageTools
class TestGetBaseUrl:
"""Test StorageSystemMixin._get_base_url()"""
def _make_storage(self, url... | fim | D4Vinci/Scrapling | python |
<|fim_suffix|>ck requests :)
<|fim_prefix|># Because I'm too lazy <|fim_middle|>to mo<|endoftext|> | fim | D4Vinci/Scrapling | python |
<|fim_suffix|>etch(
urls["html_url"], cdp_url="blahblah"
)
with pytest.raises(Exception):
await fetcher.async_fetch(urls["html_url"], cdp_url="ws://blahblah")
<|fim_prefix|>import pytest
import pytest_httpbin
from scrapling import DynamicFetcher
DynamicFetcher.adaptive... | fim | D4Vinci/Scrapling | python |
<|fim_prefix|>import pytest
import asyncio
import pytest_httpbin
from scrapling.fetchers import AsyncDynamicSession
@pytest_httpbin.use_class_based_httpbin
@pytest.mark.asyncio
class TestAsyncDynamicSe<|fim_suffix|> assert response.status == 200
assert session.page_pool.pages_count == 0
... | fim | D4Vinci/Scrapling | python |
<|fim_prefix|>import pytest
import pytest_httpbin
from scrapling.fetchers import AsyncFetcher
AsyncFetcher.adaptive = True
@pytest.fixture
def _reset_async_fetcher_config():
"""Snapshot and restore the mutable class-level parser config around a test."""
snapshot = {k: getattr(AsyncFetcher, k) for k in Async... | fim | D4Vinci/Scrapling | python |
<|fim_prefix|>import pytest
from unittest.mock import patch, MagicMock, AsyncMock
from curl_cffi.curl import CurlError
from scrapling.engines.static import _ASyncSessionLogic as AsyncFetcherSession, AsyncFetcherClient
from scrapling.engines.toolbelt import ProxyRotator
class TestFetcherSession:
"""Test FetcherSe... | fim | D4Vinci/Scrapling | python |
<|fim_prefix|>import pytest
import pytest_httpbin
from scrapling import StealthyFetcher
StealthyFetcher.adaptive = True
@pytest_httpbin.use_class_based_httpbin
@pytest.mark.asyncio
class TestStealthyFetcher:
@pytest.fixture(scope="class")
def fetcher(self):
return StealthyFetcher
@pytest.fixtur... | fim | D4Vinci/Scrapling | python |
<|fim_prefix|>
import pytest
import asyncio
import pytest_httpbin
from scrapling.fetchers import AsyncStealthySession
@pytest_httpbin.use_class_based_httpbin
@pytest.mark.asyncio
class TestAsyncStealthySession:
"""Test AsyncStealthySession"""
# The `AsyncStealthySession` is inheriting from `StealthySession... | fim | D4Vinci/Scrapling | python |
import pytest
import pytest_httpbin
from scrapling import DynamicFetcher
DynamicFetcher.adaptive = True
@pytest_httpbin.use_class_based_httpbin
class TestDynamicFetcher:
@pytest.fixture(scope="class")
def fetcher(self):
"""Fixture to create a StealthyFetcher instance for the entire test class"""
... | fim | D4Vinci/Scrapling | python |
<|fim_prefix|>import pytest
import pytest_httpbin
from scrapling import Fetcher
Fetcher.adaptive = True
@pytest.fixture
def _reset_fetcher_config():
"""Snapshot and restore the mutable class-level parser config around a test."""
snapshot = {k: getattr(Fetcher, k) for k in Fetcher.parser_keywords}
try:
... | fim | D4Vinci/Scrapling | python |
<|fim_prefix|>import pytest
from unittest.mock import patch, MagicMock
from curl_cffi.curl import CurlError
from scrapling.engines.static import _SyncSessionLogic as FetcherSession, FetcherClient
from scrapling.engines.toolbelt import ProxyRotator
class TestFetcherSession:
"""Test FetcherSession functionality"""... | fim | D4Vinci/Scrapling | python |
<|fim_suffix|>g.solve_cloudflare is True
assert session._config.wait == 1000
assert session._config.timeout == 60000
assert session.context is not None
# Test Cloudflare detection
for cloudflare_type in ('managed', 'interactive', 'non-interactive'):
... | fim | D4Vinci/Scrapling | python |
<|fim_prefix|>import pytest
from scrapling.engines.toolbelt.custom import BaseFetcher
class TestBaseFetcher:
"""Test BaseFetcher configuration functionality"""
def test_default_configuration(self):
"""Test default configuration values"""
config = BaseFetcher.display_config()
assert ... | fim | D4Vinci/Scrapling | python |
<|fim_suffix|>LT_ARGS
# assert "--incognito" in STEALTH_ARGS
assert "--disable-blink-features=AutomationControlled" in STEALTH_ARGS
<|fim_prefix|>from scrapling.engines.constants import EXTRA_RESOURCES, STEALTH_ARGS, HARMFUL_ARGS, DEFAULT_ARGS
class TestConstants:
"""Test constant values"""
d... | fim | D4Vinci/Scrapling | python |
<|fim_suffix|> accepts None."""
# This should not raise any type errors
session = FetcherSession(impersonate=None)
assert session._default_impersonate is None
<|fim_prefix|>"""Test suite for list-based impersonate parameter functionality."""
import pytest
import pytest_httpbin
from unittest.mock... | fim | D4Vinci/Scrapling | python |
<|fim_prefix|>"""Tests for _merge_request_args to ensure browser-only kwargs are excluded.
Regression tests for https://githu<|fim_suffix|>sert "block_ads" not in args
def test_google_search_excluded(self):
"""google_search is a browser-engine param and should be stripped."""
args = self._build_ar... | fim | D4Vinci/Scrapling | python |
<|fim_prefix|>import pytest
from unittest.mock import Mock
from scrapling.engines._browsers._page import PageInfo, PagePool
class TestPageInfo:
"""Test PageInfo functionality"""
def test_page_info_creation(self):
"""Test PageInfo creation"""
mock_page = Mock()
page_info = PageInfo(moc... | fim | D4Vinci/Scrapling | python |
<|fim_prefix|>import pytest
import random
from threading import Thread
from concurrent.futures import ThreadPoolExecutor
from scrapling.engines.toolbelt import ProxyRotator, is_proxy_error, cyclic_rotation
class TestCyclicRotationStrategy:
"""Test the default cyclic_rotation strategy function"""
def test_cy... | fim | D4Vinci/Scrapling | python |
<|fim_suffix|>ck_curl_response.cookies = {"session": "abc"}
mock_curl_response.headers = {"Content-Type": "text/html"}
mock_curl_response.request.headers = {"User-Agent": "Test"}
mock_curl_response.request.method = "GET"
mock_curl_response.history = []
response = ResponseFactory... | fim | D4Vinci/Scrapling | python |
<|fim_suffix|> in AD_DOMAINS
class TestBlockAdsConfig:
"""Test that block_ads merges ad domains into blocked_domains at config level."""
def test_block_ads_populates_blocked_domains(self):
from scrapling.engines._browsers._validators import PlaywrightConfig
config = PlaywrightConfig(block_ad... | fim | D4Vinci/Scrapling | python |
<|fim_prefix|>import pytest
from scrapling.engines._browsers._validators import (
validate,
StealthConfig,
PlaywrightConfig,
)
class TestValidators:
"""Test configuration validators"""
def test_playwright_config_valid(self):
"""Test valid PlaywrightConfig"""
params = {
... | fim | D4Vinci/Scrapling | python |
<|fim_suffix|>rue)
old_page.css("#target", identifier="target", auto_save=True)
# Before the fix this raised `IndexError: list index out of range` because the
# guard checked `elements is not None` but relocate() returns [] (never None).
result = new_page.css(
"#target", id... | fim | D4Vinci/Scrapling | python |
<|fim_prefix|>"""
Tests for Selector.iterancestors() and Selector.find_ancestor() methods.
Target file: tests/parser/test_general.py (append to TestElementNavigation class)
"""
import pytest
from scrapling import Selector
@pytest.fixture
def nested_page():
html = """
<html><body>
<div id="level1">
... | fim | D4Vinci/Scrapling | python |
<|fim_prefix|>import pytest
import json
from scrapling import Selector
from scrapling.core.custom_types import AttributesHandler
class TestAttributesHandler:
"""Test AttributesHandler functionality"""
@pytest.fixture
def sample_html(self):
return """
<html>
<body>
... | fim | D4Vinci/Scrapling | python |
<|fim_prefix|>"""
Tests for Selector.find_similar() with non-default parameters.
Target file: tests/parser/test_general.py (append to TestSimilarElements class)
"""
import pytest
from scrapling import Selector
@pytest.fixture
def product_page():
html = """
<html><body>
<div class="product-list">
... | fim | D4Vinci/Scrapling | python |
import pickle
import time
import logging
import pytest
from cssselect import SelectorError, SelectorSyntaxError
from scrapling import Selector
logging.getLogger("scrapling").setLevel(logging.DEBUG)
@pytest.fixture
def html_content():
return """
<html>
<head>
<title>Complex Web Page</title>
... | fim | D4Vinci/Scrapling | python |
<|fim_prefix|>import re
import pytest
from unittest.mock import Mock
from scrapling import Selector, Selectors
from scrapling.core.custom_types import TextHandler, TextHandlers
from scrapling.core.storage import SQLiteStorageSystem
class TestSelectorAdvancedFeatures:
"""Test advanced Selector features like adapt... | fim | D4Vinci/Scrapling | python |
<|fim_prefix|>"""
Tests for Selectors.filter() method edge cases.
Target file: tests/parser/test_parser_advanced.py (append to TestAdvancedSelectors class)
"""
import pytest
from scrapling import Selector, Selectors
@pytest.fixture
def page():
html = """
<html><body>
<ul>
<li class="item" ... | fim | D4Vinci/Scrapling | python |
<|fim_suffix|>erator[Dict[str, Any] | Request | None, None]:
yield {"url": str(response)}
async def on_start(self, resuming: bool = False) -> None:
pass
async def on_close(self) -> None:
pass
async def on_error(self, request: Request, error: Exception) -> None:
pass
a... | fim | D4Vinci/Scrapling | python |
<|fim_prefix|>"""Tests for the CheckpointManager and CheckpointData classes."""
import pickle
import tempfile
from pathlib import Path
import pytest
import anyio
from scrapling.spiders.request import Request
from scrapling.spiders.checkpoint import CheckpointData, CheckpointManager
class TestCheckpointData:
""... | fim | D4Vinci/Scrapling | python |
<|fim_suffix|> engine.crawl()
assert stats.requests_count == 2
assert stats.items_scraped == 2
@pytest.mark.asyncio
async def test_crawl_with_download_delay(self):
spider = MockSpider(download_delay=0.01)
engine = _make_engine(spider=spider)
stats = await engine.crawl(... | fim | D4Vinci/Scrapling | python |
<|fim_prefix|>"""Tests for force-stop checkpoint preservation in CrawlerEngine.
Regression tests for the bug where force-stop (second Ctrl+C) called
cancel_scope.cancel() BEFORE saving the checkpoint, causing:
1. _save_checkpoint() to be aborted by anyio's Cancelled exception
2. self.paused never set to True
3. The fi... | fim | D4Vinci/Scrapling | python |
<|fim_prefix|>"""Tests for `LinkExtractor`."""
import re
import pytest
from scrapling.engines.toolbelt.custom import Response
from scrapling.spiders.links import IGNORED_EXTENSIONS, LinkExtractor
def _make_response(html: str, url: str = "https://example.com/page") -> Response:
"""Build a minimal Response wrapp... | fim | D4Vinci/Scrapling | python |
<|fim_suffix|> yield {"data": "test"}
original = Request("https://example.com", callback=parse_page)
# Check getstate stores callback name
state = original.__getstate__()
assert state["_callback_name"] == "parse_page"
assert state["callback"] is None
def test_pickle_w... | fim | D4Vinci/Scrapling | python |
<|fim_prefix|>"""Tests for the result module (ItemList, CrawlStats, CrawlResult)."""
import json
import tempfile
from pathlib import Path
import pytest
from scrapling.spiders.result import ItemList, CrawlStats, CrawlResult
class TestItemList:
"""Test ItemList functionality."""
def test_itemlist_is_list(se... | fim | D4Vinci/Scrapling | python |
<|fim_suffix|>-------------------------------------
# Tests: get_delay_directives
# ---------------------------------------------------------------------------
class TestGetDelayDirectives:
@pytest.mark.asyncio
async def test_returns_crawl_delay_when_set(self):
mgr = RobotsTxtManager(make_fetch_fn(con... | fim | D4Vinci/Scrapling | python |
<|fim_suffix|>!", b"fp3_bytes_padded!"}
data = CheckpointData(requests=checkpoint_requests, seen=checkpoint_seen)
scheduler.restore(data)
assert len(scheduler) == 2
@pytest.mark.asyncio
async def test_restore_seen_set(self):
"""Test that restore sets up seen fingerprints."""
... | fim | D4Vinci/Scrapling | python |
"""Tests for the SessionManager class."""
from unittest.mock import AsyncMock, PropertyMock
from scrapling.core._types import Any
import pytest
from scrapling.spiders.session import SessionManager
from scrapling.spiders.request import Request
class MockSession: # type: ignore[type-arg]
"""Mock session for tes... | fim | D4Vinci/Scrapling | python |
<|fim_prefix|>"""Tests for `SitemapSpider`."""
import gzip
import pickle
import pytest
from scrapling.engines.toolbelt.custom import Response
from scrapling.spiders.links import LinkExtractor
from scrapling.spiders.request import Request
from scrapling.spiders.templates.sitemap import SitemapSpider
from scrapling.sp... | fim | D4Vinci/Scrapling | python |
<|fim_suffix|>f):
"""Test that not adding any sessions raises SessionConfigurationError."""
class NoSessionSpider(Spider):
name = "no_session_spider"
def configure_sessions(self, manager: SessionManager) -> None:
pass # Don't add any sessions
async... | fim | D4Vinci/Scrapling | python |
"""Tests for `CrawlSpider` and `CrawlRule`."""
import pickle
import pytest
from scrapling.engines.toolbelt.custom import Response
from scrapling.spiders.links import LinkExtractor
from scrapling.spiders.request import Request
from scrapling.spiders.templates import CrawlRule, CrawlSpider
from scrapling.core._types i... | fim | D4Vinci/Scrapling | python |
<|fim_suffix|>uffer buffer[1];
unsigned char *printed = NULL;
memset(buffer, 0, sizeof(buffer));
/* create buffer */
buffer->buffer = (unsigned char*) hooks->allocate(default_buffer_size);
buffer->length = default_buffer_size;
buffer->format = format;
buffer->hooks = *hooks;
if (buffer... | fim | DaveGamble/cJSON | c |
<|fim_prefix|>/*
Copyright (c) 2009-2017 Dave Gamble and cJSON contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
t... | fim | DaveGamble/cJSON | c |
<|fim_suffix|>string, to_child->string);
}
else
{
diff = -1;
}
}
else
{
diff = 1;
}
if (diff < 0)
{
/* from has a value that to doesn't have -> remove */
cJSON_AddItemToOb... | fim | DaveGamble/cJSON | c |
<|fim_suffix|>nst cJSON * const patches);
/*
// Note that ApplyPatches is NOT atomic on failure. To implement an atomic ApplyPatches, use:
//int cJSONUtils_AtomicApplyPatches(cJSON **object, cJSON *patches)
//{
// cJSON *modme = cJSON_Duplicate(*object, 1);
// int error = cJSONUtils_ApplyPatches(modme, patches);... | fim | DaveGamble/cJSON | c |
<|fim_prefix|>/*
Copyright (c) 2009-2017 Dave Gamble and cJSON contributors
Permission is hereby granted, free of charge,<|fim_suffix|>matted(item);
}
}
if (printed_json == NULL)
{
status = EXIT_FAILURE;
goto cleanup;
}
printf("%s\n", prin... | fim | DaveGamble/cJSON | c |
<|fim_suffix|>on = cJSON_ParseWithOpts((const char*)data + offset, NULL, require_termination);
if(json == NULL) return 0;
if(buffered)
{
printed_json = cJSON_PrintBuffered(json, 1, formatted);
}
else
{
/* unbuffered printing */
if(formatted)
{
printe... | fim | DaveGamble/cJSON | c |
<|fim_prefix|>#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
int LLVMFuzzerTestOneInput(const<|fim_suffix|>err;
}
if(fread(buf, (size_t)siz_buf, 1, f) != 1)
{
fprintf(stderr, "fread() failed\n");
goto err;
}
(void)LLVMFuzzerTestOneInput((uint8_t*)buf, (size_t)siz_buf);... | fim | DaveGamble/cJSON | c |
<|fim_prefix|>/*
Copyright (c) 2009-2017 Dave Gamble and cJSON contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
t... | fim | DaveGamble/cJSON | c |
<|fim_suffix|>, 42);
TEST_ASSERT_NOT_NULL(number = cJSON_GetObjectItemCaseSensitive(root, "number"));
TEST_ASSERT_EQUAL_INT(number->type, cJSON_Number);
TEST_ASSERT_EQUAL_DOUBLE(number->valuedouble, 42);
TEST_ASSERT_EQUAL_INT(number->valueint, 42);
cJSON_Delete(root);
}
static void cjson_add_num... | fim | DaveGamble/cJSON | c |
<|fim_prefix|>/*
<|fim_suffix|>child(item) TEST_ASSERT_NOT_NULL_MESSAGE(item->child, "Item doesn't have a child.")
#define assert_has_no_child(item) TEST_ASSERT_NULL_MESSAGE(item->child, "Item has a child.")
#define assert_is_invalid(item) \
assert_has_type(item, cJSON_Invalid);\
assert_not_in_list(item);\
assert_h... | fim | DaveGamble/cJSON | c |
<|fim_prefix|>/*
Copyright (c) 2009-2017 Dave Gamble and cJSON contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
t... | fim | DaveGamble/cJSON | c |
<|fim_suffix|>o.h>
#include <stdlib.h>
#include <string.h>
#include "unity/examples/unity_config.h"
#include "unity/src/unity.h"
#include "common.h"
#include "../cJSON_Utils.h"
static cJSON *parse_test_file(const char * const filename)
{
char *file = NULL;
cJSON *json = NULL;
file = read_file(filename);
... | fim | DaveGamble/cJSON | c |
<|fim_prefix|>/*
Copyright (c) 2009-2019 Dave Gamble and cJSON contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
t... | fim | DaveGamble/cJSON | c |
<|fim_prefix|>/*
Copyright (c) 2009-2017 Dave Gamble and cJSON contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
t... | fim | DaveGamble/cJSON | c |
<|fim_suffix|> NULL));
TEST_ASSERT_NULL(cJSONUtils_FindPointerFromObjectTo(NULL, item));
cJSONUtils_SortObject(NULL);
cJSONUtils_SortObjectCaseSensitive(NULL);
cJSON_Delete(item);
}
int main(void)
{
UNITY_BEGIN();
RUN_TEST(cjson_utils_functions_shouldnt_crash_with_null_pointers);
return ... | fim | DaveGamble/cJSON | c |
<|fim_suffix|>patch);
patchedtext = cJSON_PrintUnformatted(from);
TEST_ASSERT_EQUAL_STRING(merges[i][2], patchedtext);
cJSON_Delete(from);
cJSON_Delete(to);
cJSON_Delete(patch);
free(patchedtext);
}
}
int main(void)
{
UNITY_BEGIN();
RUN_TEST(json_pointer_te... | fim | DaveGamble/cJSON | c |
<|fim_suffix|>y("3.14");
assert_not_array("\"[]hello world!\n\"");
}
int CJSON_CDECL main(void)
{
/* initialize cJSON item */
memset(item, 0, sizeof(cJSON));
UNITY_BEGIN();
RUN_TEST(parse_array_should_parse_empty_arrays);
RUN_TEST(parse_array_should_parse_arrays_with_one_element);
RUN_TEST... | fim | DaveGamble/cJSON | c |
<|fim_suffix|>3_wo_null, sizeof(test_13) - 1);
TEST_ASSERT_NOT_NULL_MESSAGE(tree, "Failed to parse valid json.");
if (tree != NULL)
{
cJSON_Delete(tree);
}
}
static void test14_should_not_be_parsed(void)
{
cJSON *tree = NULL;
const char test_14[] = "{" \
... | fim | DaveGamble/cJSON | c |
/*
Copyright (c) 2009-2017 Dave Gamble and cJSON contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, m... | fim | DaveGamble/cJSON | c |
<|fim_prefix|>/*
Copyright (c) 2009-2017 Dave Gamble and cJSON contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
t... | fim | DaveGamble/cJSON | c |
<|fim_suffix|> "FALSE",
"array",
"world",
"object"
};
assert_parse_object("{\"one\":1, \"NULL\":null, \"TRUE\":true, \"FALSE\":false, \"array\":[], \"world\":\"hello\", \"object\":{}}");
node = item->child;
for (
i = 0;
... | fim | DaveGamble/cJSON | c |
<|fim_suffix|>hould_not_overflow_with_closing_backslash);
return UNITY_END();
}
<|fim_prefix|>/*
Copyright (c) 2009-2017 Dave Gamble and cJSON contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to dea... | fim | DaveGamble/cJSON | c |
<|fim_suffix|>E SOFTWARE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "unity/examples/unity_config.h"
#include "unity/src/unity.h"
#include "common.h"
static cJSON item[1];
static void assert_is_value(cJSON *value_item, int type)
{
TEST_ASSERT_NOT_NULL_MESSAGE(value_item, "Item is NUL... | fim | DaveGamble/cJSON | c |
/*
Copyright (c) 2009-2017 Dave Gamble and cJSON contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, m... | fim | DaveGamble/cJSON | c |
<|fim_suffix|>rt_print_array("[1]", "[1]");
assert_print_array("[\"hello!\"]", "[\"hello!\"]");
assert_print_array("[[]]", "[[]]");
assert_print_array("[null]", "[null]");
}
static void print_array_should_print_arrays_with_multiple_elements(void)
{
assert_print_array("[1, 2, 3]", "[1,2,3]");
assert... | fim | DaveGamble/cJSON | c |
<|fim_prefix|>/*
Copyright (c) 2009-2017 Dave Gamble and cJSON contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
t... | fim | DaveGamble/cJSON | c |
/*
Copyright (c) 2009-2017 Dave Gamble and cJSON contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, m... | fim | DaveGamble/cJSON | c |
<|fim_prefix|>/*
Copyright (c) 2009-2017 Dave Gamble and cJSON contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
t... | fim | DaveGamble/cJSON | c |
<|fim_suffix|>lue("null");
}
static void print_value_should_print_true(void)
{
assert_print_value("true");
}
static void print_value_should_print_false(void)
{
assert_print_value("false");
}
static void print_value_should_print_number(void)
{
assert_print_value("1.5");
}
static void print_value_should_p... | fim | DaveGamble/cJSON | c |
<|fim_prefix|>/*
Copyright (c) 2009-2017 Dave Gamble and cJSON contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
t... | fim | DaveGamble/cJSON | c |
<|fim_prefix|># ==========================================
# Unity Project - A Test Framework for C
# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
# [Released under MIT License. Please refer to license.txt for details]
# ==========================================
if RUBY_PLATFORM =~ /(win|w)... | fim | DaveGamble/cJSON | ruby |
# ==========================================
# Unity Project - A Test Framework for C
# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
# [Released under MIT License. Please refer to license.txt for details]
# ==========================================
require "#{File.expand_path(File.dirname(_... | fim | DaveGamble/cJSON | ruby |
<|fim_prefix|># ==========================================
# Unity Project - A Test Framework for C
# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
# [Released under MIT License. Please refer to license.txt for details]
# ==========================================
# This script creates all th... | fim | DaveGamble/cJSON | ruby |
<|fim_prefix|># ==========================================
# Unity Project - A Test Framework for C
# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
# [Released under MIT License. Please refer to license.txt for details]
# ==========================================
File.expand_path(File.join(F... | fim | DaveGamble/cJSON | ruby |
<|fim_suffix|>.to_s
puts 'Tests Failed : ' + test_fail.to_s
puts 'Tests Ignored : ' + test_ignore.to_s
@total_tests = test_pass + test_fail + test_ignore
return unless @xml_out
heading = '<testsuite tests="' + @total_tests.to_s + '" failures="' + test_fail.to_s + '"' + ' skips="' + test_ignore.to... | fim | DaveGamble/cJSON | ruby |
<|fim_prefix|>#!/usr/bin/ruby
#
# unity_to_junit.rb
#
require 'fileutils'
require 'optparse'
require 'ostruct'
require 'set'
require 'pp'
VERSION = 1.0
class ArgvParser
#
# Return a structure describing the options.
#
def self.parse(args)
# The options specified on the command line will be collected in *... | fim | DaveGamble/cJSON | ruby |
<|fim_prefix|># ==========================================
# Unit<|fim_suffix|>ased under MIT License. Please refer to license.txt for details]
# ==========================================
require'yaml'
module RakefileHelpers
class TestFileFilter
def initialize(all_files = false)
@all_files = all_files
... | fim | DaveGamble/cJSON | ruby |
<|fim_suffix|> '_'
unsanitized.gsub(/[-\/\\\.\,\s]/, '_')
end
end
<|fim_prefix|>module TypeSanitizer
def self.sanitize_c_identifier(unsanitized)
# c<|fim_middle|>onvert filename to valid C identifier by replacing invalid chars with<|endoftext|> | fim | DaveGamble/cJSON | ruby |
<|fim_prefix|>#! python3
# ==========================================
# Unity Project - A Test Framework for C
# Copyright (c) 2015 Alexander Mueller / XelaRellum@web.de
# [Released under MIT License. Please refer to license.txt for details]
# Based on the ruby script by Mike Karlesky, Mark VanderVoord, Greg W... | fim | DaveGamble/cJSON | python |
<|fim_suffix|> Defaults to current directory if not specified.'
puts ' Should end in / if specified.'
puts ' root_path - Helpful for producing more verbose output if using relative paths.'
exit 1
end
protected
def get_details(_result_file, l... | fim | DaveGamble/cJSON | ruby |
<|fim_prefix|>import sys
import os
from glob import glob
from pyparsing import *
from junit_xml import TestSuite, TestCase
class UnityTestSummary:
def __init__(self):
self.report = ''
self.total_tests = 0
self.failures = 0
self.ignored = 0
self.targets = 0
self.roo... | fim | DaveGamble/cJSON | python |
<|fim_suffix|>oop finishes instead of during it! */
return i;
return 0;
}
int FunctionWhichReturnsLocalVariable(void)
{
return Counter;
}
<|fim_prefix|>
#include "ProductionCode.h"
int Counter = 0;
int NumbersToFind[9] = { 0, 34, 55, 66, 32, 11, 1, 77, 888 }; /* some obnoxious array to search that... | fim | DaveGamble/cJSON | c |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.