repo stringclasses 454
values | file_path stringlengths 5 201 | extension stringclasses 1
value | content stringlengths 8 509k | num_lines int64 3 16.9k | size_bytes int64 8 511k |
|---|---|---|---|---|---|
reflex | tests/integration/tests_playwright/test_memo.py | .py | """Integration tests for ``rx.memo`` runtime behavior.
Covers behaviors previously exercised by the deleted
``tests/integration/test_memo.py`` (Selenium): partial-application of an
``EventHandler`` prop (``event(some_value)``) and raw pass-through to an
inner event trigger (``on_change=event``). Also covers recursion ... | 266 | 8,780 |
reflex | tests/integration/tests_playwright/test_recharts.py | .py | """Integration tests for recharts graphing components."""
from collections.abc import Generator
import pytest
from playwright.sync_api import Page, expect
from reflex.testing import AppHarness
def RechartsApp():
"""App exercising several recharts chart types, static and stateful."""
import reflex as rx
... | 235 | 7,813 |
reflex | tests/integration/tests_playwright/test_backend_path.py | .py | """Integration tests for the backend_path config option.
Tests that backend endpoints mount at the configured prefix and that the
frontend baked with ``backend_path`` can still reach the backend for state
events, uploads, and health checks. Covers the no-prefix baseline and the
prefixed case for both dev and prod mode... | 152 | 5,010 |
reflex | tests/integration/tests_playwright/test_cond_match.py | .py | """Integration tests for stateful ``rx.cond`` and ``rx.match`` rendering."""
from collections.abc import Generator
import pytest
from playwright.sync_api import Page, expect
from reflex.testing import AppHarness
def CondMatchApp():
"""App exercising conditional rendering across state transitions."""
import... | 115 | 3,825 |
reflex | tests/integration/tests_playwright/test_link_hover.py | .py | from collections.abc import Generator
import pytest
from playwright.sync_api import Page, expect
from reflex.testing import AppHarness
def LinkApp():
import reflex as rx
app = rx.App()
def index():
return rx.vstack(
rx.box(height="10em"), # spacer, so the link isn't hovered initia... | 47 | 1,202 |
reflex | tests/integration/tests_playwright/test_frontend_path.py | .py | """Integration tests for the frontend_path config option.
Tests that links, redirects, assets, uploaded files, and on_load events all
work correctly when the app is served from a subpath (e.g., /prefix) and also
when served from the root (no frontend_path set).
Covers dev and prod modes via ``app_harness_env`` parame... | 552 | 20,193 |
reflex | tests/integration/tests_playwright/test_router_query.py | .py | """Integration tests for router URL/query sync and navigation semantics.
Reproduces and guards https://github.com/reflex-dev/reflex/issues/6603 and
codifies the agreed behavior of the navigation primitives:
* A direct ``rx.call_script(window.history.replaceState(...))`` changes the
browser URL but is **not** a navi... | 278 | 10,065 |
reflex | tests/integration/tests_playwright/test_memoize_edge_cases.py | .py | """Integration tests for auto-memoization edge cases.
These exercise components whose memoization needs special care:
- Snapshot boundaries (``recursive=False``) such as ``AccordionTrigger`` whose
state-dependent logic lives in a descendant. Without the snapshot wrapper
the cond's state read leaks into the page m... | 262 | 9,472 |
reflex | tests/integration/tests_playwright/test_datetime_operations.py | .py | from collections.abc import Generator
import pytest
from playwright.sync_api import Page, expect
from reflex.testing import AppHarness
def DatetimeOperationsApp():
from datetime import date, datetime, timedelta, timezone
import reflex as rx
class DtOperationsState(rx.State):
date1: datetime = ... | 204 | 10,062 |
reflex | tests/integration/tests_playwright/test_code_block.py | .py | """Integration tests for the code block component."""
from collections.abc import Generator
import pytest
from playwright.sync_api import Page, expect
from reflex.testing import AppHarness
DEFAULT_COPY_CODE = "print('copied from default button')"
CUSTOM_COPY_CODE = "print('copied from custom button')"
def CodeBlo... | 224 | 7,550 |
reflex | tests/benchmarks/test_event_processing.py | .py | """Benchmark for the event processing pipeline.
Measures the time from enqueuing events via ``BaseStateEventProcessor``
to collecting all emitted ``StateUpdate`` deltas, with mock emit
callbacks that record the deltas.
"""
import asyncio
import traceback
from collections.abc import Mapping
from typing import Any
from... | 123 | 4,175 |
reflex | tests/benchmarks/test_state_proxy.py | .py | """Benchmarks for reading state vars through ``MutableProxy``.
Reading a *mutable* var (list/dict/dataclass) returns a ``MutableProxy``.
Mutable element reads are wrapped in child proxies via ``_wrap_mutable``,
while non-mutable element reads skip the wrapping machinery through a
fast-path mutability check. Reading a ... | 96 | 2,882 |
reflex | tests/benchmarks/test_evaluate.py | .py | from collections.abc import Callable
from pytest_codspeed import BenchmarkFixture
from reflex_base.components.component import Component
from reflex_base.plugins import CompilerHooks
from reflex.app import UnevaluatedPage
from reflex.compiler.plugins import DefaultPagePlugin
def test_evaluate_page(
unevaluated_... | 24 | 733 |
reflex | tests/benchmarks/fixtures.py | .py | from collections.abc import Callable
from dataclasses import dataclass
from typing import Any, cast
import pytest
from pydantic import BaseModel
from reflex_base.components.component import BaseComponent, Component
from reflex_base.plugins import CompileContext, PageContext
import reflex as rx
from reflex.compiler.pl... | 429 | 14,831 |
reflex | tests/benchmarks/test_compilation.py | .py | import copy
from pytest_codspeed import BenchmarkFixture
from reflex_base.components.component import Component
from reflex_base.plugins import CompileContext, CompilerHooks, PageContext
from reflex.app import UnevaluatedPage
from reflex.compiler import compiler
from reflex.compiler.plugins import DefaultCollectorPlu... | 134 | 4,029 |
reflex | tests/benchmarks/test_event_creation.py | .py | """Benchmarks for event creation and conversion APIs."""
from typing import Any
import pytest
from pytest_codspeed import BenchmarkFixture
from reflex_base.event import Event, EventHandler, EventSpec
import reflex as rx
from .fixtures import BenchmarkState
def test_console_log(benchmark: BenchmarkFixture):
""... | 112 | 3,212 |
reflex | tests/benchmarks/conftest.py | .py | from .fixtures import evaluated_page, unevaluated_page
__all__ = ["evaluated_page", "unevaluated_page"]
| 4 | 105 |
reflex | tests/units/test_style.py | .py | from __future__ import annotations
from typing import Any
import pytest
from reflex_base.components.component import evaluate_style_namespaces
from reflex_base.style import Style
from reflex_base.utils.exceptions import ReflexError
from reflex_base.vars import VarData
from reflex_base.vars.base import LiteralVar, Var... | 522 | 18,218 |
reflex | tests/units/test_event.py | .py | import json
from collections.abc import Callable
from typing import Any, cast
import pytest
from reflex_base.constants.compiler import Hooks, Imports
from reflex_base.event import (
BACKGROUND_TASK_MARKER,
Event,
EventChain,
EventChainVar,
EventHandler,
EventSpec,
LambdaEventCallback,
c... | 1,241 | 40,862 |
reflex | tests/units/mock_redis.py | .py | """Mock implementation of redis for unit testing."""
import asyncio
import contextlib
import fnmatch
import time
from collections.abc import AsyncGenerator, Callable
from typing import Any
from unittest.mock import AsyncMock, Mock
from redis.asyncio import Redis
from redis.typing import EncodableT, KeyT
from reflex.... | 304 | 9,756 |
reflex | tests/units/test_page.py | .py | from reflex_base.registry import RegistrationContext
from reflex import text
from reflex.page import page
def test_page_decorator(clean_registration_context: RegistrationContext):
"""@page stores the decorated function on the current registration context.
Args:
clean_registration_context: A fresh re... | 62 | 1,785 |
reflex | tests/units/test_lighthouse_utils.py | .py | """Unit tests for Lighthouse benchmark utilities."""
import subprocess
from types import SimpleNamespace
import pytest
from tests.integration import lighthouse_utils
@pytest.fixture(autouse=True)
def clear_lighthouse_command_cache():
"""Reset cached Lighthouse command preparation between tests."""
lighthou... | 157 | 5,032 |
reflex | tests/units/test_route.py | .py | import pytest
from pytest_mock import MockerFixture
from reflex_base import constants
from reflex.app import App
from reflex.route import get_route_args, get_router, verify_route_validity
@pytest.mark.parametrize(
("route_name", "expected"),
[
("/users/[id]", {"id": constants.RouteArgType.SINGLE}),
... | 130 | 3,903 |
reflex | tests/units/test_testing.py | .py | """Unit tests for the included testing tools."""
import sys
from types import ModuleType, SimpleNamespace
from unittest import mock
import pytest
import reflex_base.config
from reflex_base.components.memo import MEMOS
from reflex_base.constants import IS_WINDOWS
from reflex_base.environment import environment
from re... | 190 | 6,365 |
reflex | tests/units/test_state_tree.py | .py | """Specialized test for a larger state tree."""
from collections.abc import AsyncGenerator
import pytest
import pytest_asyncio
from reflex_base.constants.state import FIELD_MARKER
import reflex as rx
from reflex.istate.manager import StateManager
from reflex.istate.manager.redis import StateManagerRedis
from reflex.... | 387 | 8,995 |
reflex | tests/units/test_make_pyi.py | .py | """Unit tests for scripts/make_pyi.py (the .pyi generation driver).
Covers the dispatch logic that decides, per invocation:
- which targets are scanned,
- whether ``pyi_hashes.json`` is pruned (full run) or merged (partial run),
- whether the ``.pyi_generator_last_run`` marker is written,
and the commit-reachability ... | 339 | 11,031 |
reflex | tests/units/test_app.py | .py | from __future__ import annotations
import asyncio
import contextlib
import contextvars
import functools
import io
import json
import re
import unittest.mock
import uuid
from collections.abc import Generator
from contextlib import nullcontext as does_not_raise
from importlib.util import find_spec
from pathlib import Pa... | 4,260 | 142,326 |
reflex | tests/units/test_sqlalchemy.py | .py | import math
from pathlib import Path
from unittest import mock
import pytest
from reflex_base.utils.serializers import serializer
import reflex.constants
import reflex.model
from reflex.model import (
ModelRegistry,
alembic_autogenerate,
alembic_init,
get_engine,
migrate,
sqla_session,
)
from ... | 297 | 9,425 |
reflex | tests/units/test_config.py | .py | import multiprocessing
import os
import threading
import time
from pathlib import Path
from typing import Any
import pytest
import reflex_base.config
from pytest_mock import MockerFixture
from reflex_base.constants import Endpoint, Env
from reflex_base.plugins import Plugin
from reflex_base.plugins.sitemap import Site... | 888 | 31,627 |
reflex | tests/units/test_optional_pydantic.py | .py | """Verify reflex imports and works when pydantic is not installed."""
import subprocess
import sys
# Runs in a subprocess with pydantic (and the db extras that require it)
# blocked, mirroring the "without db dependencies" CI job.
_SCRIPT = """
import sys
BLOCKED = ("pydantic", "sqlmodel", "alembic", "sqlalchemy")
... | 74 | 2,011 |
reflex | tests/units/test_health_endpoint.py | .py | import json
from importlib.util import find_spec
from unittest.mock import MagicMock, Mock
import pytest
from pytest_mock import MockerFixture
from redis.exceptions import RedisError
from reflex.app import health
from reflex.model import get_db_status
from reflex.utils.prerequisites import get_redis_status
pytest.im... | 165 | 5,148 |
reflex | tests/units/test_environment.py | .py | """Tests for the environment module."""
import enum
import os
import tempfile
from pathlib import Path
from typing import Annotated
from unittest.mock import patch
import pytest
from reflex_base import constants
from reflex_base.environment import (
EnvironmentVariables,
EnvVar,
ExistingPath,
Performa... | 685 | 25,832 |
reflex | tests/units/test_var.py | .py | import decimal
import json
import math
import operator as op
import re
import typing
from collections.abc import Mapping, Sequence
from datetime import date, datetime, timedelta, timezone
from typing import cast
import pytest
from pandas import DataFrame
from pytest_mock import MockerFixture
from reflex_base.constants... | 2,311 | 69,147 |
reflex | tests/units/test_telemetry.py | .py | import asyncio
import importlib.metadata
import threading
import uuid
from types import SimpleNamespace
import pytest
from packaging.version import parse as parse_python_version
from pytest_mock import MockerFixture
from reflex.utils import telemetry
@pytest.fixture(autouse=True)
def _drain_telemetry_executor():
... | 748 | 27,599 |
reflex | tests/units/test_check_min_deps.py | .py | """Unit tests for scripts/check_min_deps.py (the minimum-dependency-version checker)."""
import sys
from pathlib import Path
import pytest
# The script relies on ``tomllib`` (stdlib only on 3.11+); on 3.10 it falls back to the
# ``tomli`` backport. Skip the whole module when neither is available, so the tests still
... | 318 | 11,839 |
reflex | tests/units/test_prerequisites.py | .py | import json
import shutil
import tempfile
import uuid
from collections.abc import Callable, Generator
from dataclasses import dataclass
from pathlib import Path
from typing import Protocol
import pytest
from click.testing import CliRunner
from reflex_base import constants
from reflex_base.config import Config
from ref... | 1,956 | 63,810 |
reflex | tests/units/test_db_config.py | .py | import urllib.parse
import pytest
from reflex_base.config import DBConfig
@pytest.mark.parametrize(
("engine", "username", "password", "host", "port", "database", "expected_url"),
[
(
"postgresql",
"user",
"pass",
"localhost",
5432,
... | 204 | 6,137 |
reflex | tests/units/test_release.py | .py | """Unit tests for scripts/release.py (the changelog-driven release helper)."""
import io
import json
import subprocess
import sys
import tarfile
import zipfile
from pathlib import Path
import pytest
from packaging.version import Version
# The script relies on ``tomllib`` (stdlib only on 3.11+); on 3.10 it falls back... | 780 | 28,283 |
reflex | tests/units/test_model.py | .py | import math
from pathlib import Path
from unittest import mock
import pytest
from reflex_base.constants.state import FIELD_MARKER
from reflex_base.event import Event
import reflex.constants
import reflex.model
from reflex.model import (
Model,
ModelRegistry,
alembic_autogenerate,
alembic_init,
get... | 301 | 8,894 |
reflex | tests/units/test_state.py | .py | from __future__ import annotations
import asyncio
import copy
import dataclasses
import datetime
import functools
import json
import math
import os
import sys
import threading
from collections.abc import AsyncGenerator, Callable, Mapping
from textwrap import dedent
from typing import Any, ClassVar
from unittest.mock i... | 5,196 | 164,662 |
reflex | tests/units/test_attribute_access_type.py | .py | from __future__ import annotations
from typing import List # noqa: UP035
import attrs
import pytest
from reflex_base.utils.types import GenericType, get_attribute_access_type
import reflex as rx
pytest.importorskip("sqlalchemy")
pytest.importorskip("sqlmodel")
pytest.importorskip("pydantic")
import pydantic
impor... | 423 | 11,491 |
reflex | tests/units/conftest.py | .py | """Test fixtures."""
import platform
import traceback
import uuid
from collections.abc import AsyncGenerator, Generator, Mapping
from typing import Any
from unittest import mock
import pytest
import pytest_asyncio
from reflex_base.components.memo import MEMOS
from reflex_base.event import Event, EventSpec
from reflex... | 520 | 15,074 |
reflex | tests/units/app_mixins/test_lifespan.py | .py | """Unit tests for lifespan app mixin behavior."""
from __future__ import annotations
import asyncio
import contextlib
import pytest
from reflex_base.utils.exceptions import InvalidLifespanTaskTypeError
from starlette.applications import Starlette
from reflex.app_mixins.lifespan import LifespanMixin
def test_regis... | 125 | 3,920 |
reflex | tests/units/reflex_release/test_versions.py | .py | """Tests for reflex_release.versions."""
from __future__ import annotations
import pytest
from packaging.version import Version
from reflex_release.actions import ReleaseError
from reflex_release.versions import (
ACTIONS,
FINAL_ACTIONS,
next_version,
release_date_today,
)
@pytest.mark.parametrize(
... | 85 | 3,040 |
reflex | tests/units/reflex_release/test_dist.py | .py | """Tests for reflex_release.dist."""
from __future__ import annotations
import tarfile
import zipfile
from pathlib import Path
import pytest
from packaging.version import Version
from reflex_release.actions import ReleaseError
from reflex_release.dist import dist_metadata, normalize_name, pin_exact, verify_dist
MET... | 154 | 5,544 |
reflex | tests/units/reflex_release/test_discovery.py | .py | """Tests for reflex_release.discovery."""
from __future__ import annotations
from pathlib import Path
import pytest
from reflex_release.actions import ReleaseError
from reflex_release.changelog import DEFAULT_TITLE_FORMAT
from reflex_release.config import Config, load_config
from reflex_release.discovery import titl... | 49 | 1,612 |
reflex | tests/units/reflex_release/test_config.py | .py | """Tests for reflex_release.config."""
from __future__ import annotations
from pathlib import Path
import pytest
from packaging.version import Version
from reflex_release.actions import ReleaseError
from reflex_release.config import Config, is_final, load_config
def write_config(repo: Path, body: str) -> None:
... | 357 | 13,068 |
reflex | tests/units/reflex_release/test_devpins.py | .py | """Tests for reflex_release.devpins."""
from __future__ import annotations
from pathlib import Path
import pytest
from reflex_release.actions import ReleaseError
from reflex_release.config import Config
from reflex_release.devpins import (
check_dev_pins,
parse_requirement,
published_dependencies,
)
@p... | 79 | 2,748 |
reflex | tests/units/reflex_release/test_changelog.py | .py | """Tests for reflex_release.changelog."""
from __future__ import annotations
import pytest
from packaging.version import Version
from reflex_release.actions import ReleaseError
from reflex_release.changelog import (
collapse_prereleases,
extract_notes,
heading_version,
latest_version,
parse_sectio... | 247 | 5,698 |
reflex | tests/units/reflex_release/test_scaffold.py | .py | """Tests for reflex_release.scaffold."""
from __future__ import annotations
import re
from pathlib import Path
import pytest
import yaml
from reflex_release.actions import ReleaseError
from reflex_release.commands import _split_selection
from reflex_release.config import POST_RELEASE_INPUTS, Config, load_config
from... | 656 | 23,643 |
reflex | tests/units/reflex_release/test_commands.py | .py | """Tests for the reflex_release subcommands."""
from __future__ import annotations
import json
import shutil
from collections.abc import Callable
from pathlib import Path
import pytest
from reflex_release import commands
from reflex_release.actions import ReleaseError
from reflex_release.config import Config, load_c... | 957 | 34,128 |
reflex | tests/units/reflex_release/test_cli.py | .py | """Tests for the reflex_release command line interface."""
from __future__ import annotations
import json
from collections.abc import Callable
from pathlib import Path
import pytest
from reflex_release.cli import find_root, main
Outputs = Callable[[], dict[str, str]]
def test_find_root_walks_up_to_the_pyproject(r... | 100 | 3,467 |
reflex | tests/units/reflex_release/conftest.py | .py | """Fixtures for the reflex-release unit tests."""
from __future__ import annotations
import subprocess
from collections.abc import Callable
from pathlib import Path
import pytest
from reflex_release.config import Config, load_config
from reflex_release.scaffold import towncrier_config_toml
ROOT_PYPROJECT = """\
[pr... | 185 | 5,005 |
reflex | tests/units/istate/test_proxy.py | .py | """Tests for reflex.istate.proxy."""
import asyncio
import dataclasses
import pickle
from asyncio import CancelledError
from contextlib import asynccontextmanager
from typing import Any
import pytest
from reflex_base.event.context import EventContext
from reflex_base.utils.exceptions import ImmutableStateError
impor... | 716 | 23,795 |
reflex | tests/units/istate/test_data.py | .py | """Tests for ReflexURL parsing, serialization, and Var attribute access."""
from collections.abc import Mapping
from urllib.parse import parse_qsl
from reflex_base.vars.object import ObjectVar
from reflex_base.vars.sequence import StringVar
import reflex as rx
from reflex.istate.data import ReflexURL, ReflexURLCaste... | 149 | 5,565 |
reflex | tests/units/istate/manager/test_manager_locks.py | .py | """Tests for state manager lock isolation."""
import asyncio
from collections.abc import Callable
from pathlib import Path
from typing import Protocol
import pytest
from reflex.istate.manager.disk import StateManagerDisk
from reflex.istate.manager.memory import StateManagerMemory
from reflex.istate.manager.redis imp... | 82 | 2,437 |
reflex | tests/units/istate/manager/test_expiration.py | .py | """Tests for state manager token expiration."""
import asyncio
import time
from collections.abc import AsyncGenerator, Callable
import pytest
import pytest_asyncio
from reflex.istate.manager.memory import StateManagerMemory
from reflex.istate.manager.token import BaseStateToken
from reflex.state import BaseState
c... | 212 | 6,723 |
reflex | tests/units/istate/manager/test_redis.py | .py | """Tests specific to redis state manager."""
import asyncio
import os
import time
import uuid
from collections.abc import AsyncGenerator
from typing import Any
import pytest
import pytest_asyncio
from reflex.istate.manager.redis import StateManagerRedis
from reflex.istate.manager.token import BaseStateToken
from ref... | 739 | 22,986 |
reflex | tests/units/istate/manager/test_token.py | .py | """Tests for StateToken, BaseStateToken, and from_legacy_token."""
import io
import pickle
import pytest
from reflex.istate.manager.token import BaseStateToken, StateToken
def test_state_token_str():
"""__str__ encodes ident and cls into 'ident/module.Class' format."""
token = StateToken(ident="abc-123", c... | 185 | 5,476 |
reflex | tests/units/reflex_cli/conftest.py | .py | """Shared fixtures for reflex_cli tests."""
import pytest
from pytest_mock import MockFixture
@pytest.fixture(autouse=True)
def mock_check_version(mocker: MockFixture) -> None:
"""Bypass the hosting-cli PyPI version check during tests.
The workspace build reports a dev version older than the published one,
... | 15 | 447 |
reflex | tests/units/reflex_cli/v2/test_secrets.py | .py | import tempfile
from pathlib import Path
from click.testing import CliRunner
from pytest_mock import MockFixture
from reflex_cli.utils import hosting
from reflex_cli.v2.deployments import hosting_cli
from typer import Typer
from typer.main import get_command
hosting_cli = (
get_command(hosting_cli) if isinstance(... | 276 | 8,626 |
reflex | tests/units/reflex_cli/v2/test_providers.py | .py | from __future__ import annotations
import json
import httpx
from click.testing import CliRunner
from pytest_mock import MockFixture
from reflex_cli.utils import hosting
from reflex_cli.v2.providers import providers_cli
runner = CliRunner()
_CLIENT = hosting.AuthenticatedClient(
token="fake-token", validated_dat... | 145 | 4,588 |
reflex | tests/units/reflex_cli/v2/test_deployments.py | .py | import importlib.metadata
from unittest.mock import MagicMock
import click
import httpx
import pytest
from pytest_mock import MockerFixture, MockFixture
from reflex_cli.v2.deployments import check_version
@pytest.mark.parametrize(
"installed_version, latest_version, should_exit",
[
("1.0.0", "1.0.0",... | 70 | 2,261 |
reflex | tests/units/reflex_cli/v2/test_gcp.py | .py | from __future__ import annotations
import os
from pathlib import Path
from unittest import mock
import httpx
import pytest
from click.testing import CliRunner
from pytest_mock import MockFixture
from reflex_cli.utils import hosting
from reflex_cli.v2.deployments import hosting_cli
from typer.main import Typer, get_co... | 1,015 | 33,086 |
reflex | tests/units/reflex_cli/v2/test_project.py | .py | import json
import httpx
from click.testing import CliRunner
from pytest_mock import MockFixture
from reflex_cli.utils import hosting
from reflex_cli.utils.exceptions import NotAuthenticatedError
from reflex_cli.v2.deployments import hosting_cli
from typer import Typer
from typer.main import get_command
hosting_cli =... | 832 | 27,573 |
reflex | tests/units/reflex_cli/v2/test_vmtypes_regions.py | .py | import json
import httpx
import pytest
from click.testing import CliRunner
from pytest_mock import MockerFixture, MockFixture
from reflex_cli.v2.deployments import hosting_cli
from typer import Typer
from typer.main import get_command
hosting_cli = (
get_command(hosting_cli) if isinstance(hosting_cli, Typer) else... | 218 | 7,623 |
reflex | tests/units/reflex_cli/v2/test_scan.py | .py | from __future__ import annotations
import io
import json
import zipfile
from pathlib import Path
from click.testing import CliRunner
from pytest_mock import MockFixture
from reflex_cli.utils import hosting
from reflex_cli.utils.exceptions import NotAuthenticatedError
from reflex_cli.v2.deployments import hosting_cli
... | 297 | 9,998 |
reflex | tests/units/reflex_cli/v2/test_cli.py | .py | from __future__ import annotations
import importlib.metadata
from collections.abc import Callable
from unittest.mock import MagicMock
import click
import httpx
import pytest
from packaging import version
from pytest_mock import MockerFixture, MockFixture
from reflex_cli.utils import hosting
from reflex_cli.v2 import ... | 1,411 | 46,812 |
reflex | tests/units/reflex_cli/v2/test_apps.py | .py | from __future__ import annotations
import json
from unittest import mock
import httpx
import pytest
from click.testing import CliRunner
from pytest_mock import MockerFixture, MockFixture
from reflex_cli.core.config import Config
from reflex_cli.utils import hosting
from reflex_cli.utils.exceptions import GetAppError
... | 1,688 | 58,700 |
reflex | tests/units/reflex_cli/utils/test_dependency.py | .py | from pathlib import Path
import pytest
from pytest_mock import MockFixture
from reflex_cli.utils.dependency import detect_encoding, is_valid_url
def test_detect_encoding_file_not_found(mocker: MockFixture):
filename = "non_existent_file.txt"
mocker.patch("pathlib.Path.exists", return_value=False)
with ... | 37 | 1,025 |
reflex | tests/units/reflex_cli/utils/test_hosting.py | .py | from __future__ import annotations
import json
from unittest.mock import mock_open
import click
import httpx
import pytest
from pytest_mock import MockerFixture, MockFixture
from reflex_cli.utils.exceptions import TokenValidationError
from reflex_cli.utils.hosting import (
AuthenticatedClient,
ScaleParams,
... | 733 | 26,161 |
reflex | tests/units/custom_components/test_custom_components.py | .py | """Unit tests for reflex/custom_components/custom_components.py."""
from __future__ import annotations
from pathlib import Path
from reflex.custom_components import custom_components
def test_make_pyi_files_delegates_recursive_scan_without_path_walk(
monkeypatch, tmp_path: Path
):
"""``_make_pyi_files`` de... | 45 | 1,400 |
reflex | tests/units/docgen/test_class_and_component.py | .py | """Tests for reflex-docgen."""
import dataclasses
import sys
from collections.abc import Callable
from importlib.util import find_spec
from typing import Any, Literal
import pytest
from reflex_base.components.component import (
DEFAULT_TRIGGERS_AND_DESC,
Component,
TriggerDefinition,
field,
)
from ref... | 663 | 22,947 |
reflex | tests/units/docgen/test_markdown.py | .py | """Tests for reflex-docgen markdown parsing."""
from pathlib import Path
import pytest
from reflex_docgen.markdown import (
BoldSpan,
CodeBlock,
CodeSpan,
ComponentPreview,
DirectiveBlock,
FrontMatter,
HeadingBlock,
ImageSpan,
ItalicSpan,
LineBreakSpan,
LinkSpan,
ListBl... | 913 | 29,364 |
reflex | tests/units/docgen/test_reflex_transformer.py | .py | """Tests for the reflex-docgen ReflexComponentTransformer."""
from reflex_docgen.markdown import HeadingBlock, TextSpan, parse_document
from reflex_docgen.markdown.transformer.reflex import ReflexComponentTransformer
import reflex as rx
from reflex.components.component import BaseComponent
_rx = ReflexComponentTrans... | 234 | 8,499 |
reflex | tests/units/utils/test_imports.py | .py | import pytest
from reflex_base.utils.imports import (
ImportDict,
ImportVar,
ParsedImportDict,
merge_imports,
parse_imports,
)
@pytest.mark.parametrize(
("import_var", "expected_name"),
[
(
ImportVar(tag="BaseTag"),
"BaseTag",
),
(
... | 121 | 3,260 |
reflex | tests/units/utils/test_format.py | .py | from __future__ import annotations
import datetime
import json
from typing import Any
import plotly.graph_objects as go
import pytest
from reflex_base.components.tags.tag import Tag
from reflex_base.constants.state import FIELD_MARKER
from reflex_base.event import (
EventChain,
EventHandler,
EventSpec,
... | 887 | 28,122 |
reflex | tests/units/utils/test_telemetry_accounting.py | .py | """Tests for ``reflex.utils.telemetry_accounting``."""
from types import SimpleNamespace
from typing import cast
from unittest.mock import MagicMock
from pytest_mock import MockerFixture
from reflex_base.config import Config
from reflex_base.plugins.sitemap import SitemapPlugin
from reflex_base.telemetry_context impo... | 441 | 14,116 |
reflex | tests/units/utils/test_precompressed_staticfiles.py | .py | """Unit tests for precompressed static file serving."""
from __future__ import annotations
import asyncio
from pathlib import Path
import pytest
from starlette.responses import FileResponse, Response
from starlette.types import Message
from reflex.utils.precompressed_staticfiles import PrecompressedStaticFiles
de... | 172 | 5,946 |
reflex | tests/units/utils/test_tasks.py | .py | import asyncio
import contextlib
import os
from unittest.mock import Mock
import pytest
from reflex.utils.tasks import ensure_task
CI = bool(os.environ.get("CI", False))
class NotSuppressedError(Exception):
"""An exception that should not be suppressed."""
@pytest.mark.asyncio
async def test_ensure_task_supp... | 121 | 3,561 |
reflex | tests/units/utils/test_export.py | .py | """Tests for reflex.utils.export."""
from __future__ import annotations
import pytest
from pytest_mock import MockerFixture
from reflex.utils import export
@pytest.fixture
def patched_export(mocker: MockerFixture) -> dict:
"""Patch out side-effecting dependencies of ``export.export()``.
Returns:
D... | 129 | 4,205 |
reflex | tests/units/utils/test_serializers.py | .py | import datetime
import decimal
import json
from enum import Enum
from pathlib import Path
from typing import Any
import pytest
from reflex_base.utils.format import json_dumps
from reflex_base.vars.base import LiteralVar
from reflex_components_core.core.colors import Color
from reflex.utils import serializers
pytest.... | 250 | 7,222 |
reflex | tests/units/utils/test_build.py | .py | """Tests for reflex.utils.build."""
from __future__ import annotations
import gzip
import json
from pathlib import Path
import pytest
import reflex_base
from pytest_mock import MockerFixture
from reflex.plugins import EmbedPlugin, Plugin
from reflex.utils import build, path_ops
def test_compress_static_output_ove... | 149 | 4,981 |
reflex | tests/units/utils/test_exec.py | .py | """Tests for development backend launchers in ``reflex.utils.exec``."""
import os
from pathlib import Path
import pytest
from pytest_mock import MockerFixture
from reflex_base.environment import environment
from reflex.utils import exec as exec_utils
DEV_BACKEND_RELOAD_ENV_NAME = environment.REFLEX_DEV_BACKEND_RELO... | 104 | 3,658 |
reflex | tests/units/utils/test_memo_paths.py | .py | """Tests for source-module capture and mirrored-path translation."""
from __future__ import annotations
import importlib.util
from pathlib import Path
from unittest.mock import patch
from reflex_base.utils import memo_paths
def _user_fn():
"""Stand-in for a user-defined function (defined in this test module)."... | 165 | 6,642 |
reflex | tests/units/utils/test_streaming_response.py | .py | from __future__ import annotations
import asyncio
from typing import Any
from unittest.mock import AsyncMock
import pytest
from reflex_base.utils.streaming_response import DisconnectAwareStreamingResponse
from starlette.requests import ClientDisconnect
@pytest.mark.asyncio
async def test_send_oserror_raises_client_... | 122 | 3,461 |
reflex | tests/units/utils/test_token_manager.py | .py | """Unit tests for TokenManager implementations."""
import asyncio
import pickle
import time
from collections.abc import Callable, Generator
from contextlib import asynccontextmanager
from unittest.mock import AsyncMock, Mock, patch
import pytest
from reflex import config
from reflex.app import EventNamespace
from re... | 737 | 25,046 |
reflex | tests/units/utils/test_telemetry_context.py | .py | """Tests for ``reflex.utils.telemetry_context``."""
from pytest_mock import MockerFixture
from reflex_base.telemetry_context import TelemetryContext
def test_get_returns_none_when_no_context_set():
"""``get()`` returns ``None`` instead of raising ``LookupError``."""
assert TelemetryContext.get() is None
de... | 97 | 3,423 |
reflex | tests/units/utils/test_processes.py | .py | """Test process utilities."""
import socket
import threading
from contextlib import closing
from unittest import mock
import pytest
from reflex.testing import DEFAULT_TIMEOUT, AppHarness
from reflex.utils.processes import is_process_on_port
def test_is_process_on_port_free_port():
"""Test is_process_on_port re... | 156 | 4,958 |
reflex | tests/units/utils/test_types.py | .py | from typing import Any, Literal, TypedDict
import pytest
from reflex_base.utils import types
from reflex_base.vars.base import Var
@pytest.mark.parametrize(
("params", "allowed_value_str", "value_str"),
[
(["size", 1, Literal["1", "2", "3"], "Heading"], "'1','2','3'", "1"),
(["size", "1", Lit... | 139 | 3,829 |
reflex | tests/units/utils/test_utils.py | .py | import os
import typing
from collections.abc import Mapping, Sequence
from functools import cached_property
from pathlib import Path
from typing import Any, ClassVar, List, Literal, NoReturn # noqa: UP035
import pytest
from packaging import version
from pytest_mock import MockerFixture
from reflex_base import constan... | 895 | 30,016 |
reflex | tests/units/vars/test_dep_tracking.py | .py | """Tests for dependency tracking functionality."""
from __future__ import annotations
import sys
import pytest
from reflex_base.utils.exceptions import VarValueError
from reflex_base.vars.dep_tracking import (
DependencyTracker,
UntrackedLocalVarError,
get_cell_value,
)
import reflex as rx
import tests.... | 617 | 20,498 |
reflex | tests/units/vars/test_dep_tracking_integration.py | .py | """Integration tests for dependency tracking with computed vars."""
from __future__ import annotations
import reflex as rx
from reflex.state import State
class IntegrationTestState(State):
"""State for integration testing with dependency tracker."""
count: int = 0
name: str = "test"
items: list[str... | 247 | 7,499 |
reflex | tests/units/vars/test_base.py | .py | from collections.abc import Mapping, Sequence
import pytest
from reflex_base.vars.base import computed_var, figure_out_type
from reflex.state import State
class CustomDict(dict[str, str]):
"""A custom dict with generic arguments."""
class ChildCustomDict(CustomDict):
"""A child of CustomDict."""
class G... | 80 | 2,272 |
reflex | tests/units/vars/test_object.py | .py | import dataclasses
from collections.abc import Sequence
from typing import Any
import pytest
from reflex_base.utils.exceptions import VarAttributeError
from reflex_base.utils.imports import ImportVar
from reflex_base.utils.types import GenericType
from reflex_base.vars.base import Var, VarData
from reflex_base.vars.nu... | 339 | 11,104 |
reflex | tests/units/vars/test_hybrid_property.py | .py | """Unit tests for reflex_base.vars.hybrid_property."""
import pytest
from reflex_base.utils.exceptions import HybridPropertyError
import reflex as rx
from reflex.experimental import hybrid_property
from reflex.vars import Var
def test_hybrid_property_getter_backend_var_access_raises():
"""A hybrid property gett... | 112 | 3,294 |
reflex | tests/units/middleware/test_hydrate_middleware.py | .py | from __future__ import annotations
import pytest
from reflex_base.registry import RegistrationContext
from reflex.app import App
from reflex.middleware.hydrate_middleware import HydrateMiddleware
from reflex.state import State, StateUpdate
class TestState(State):
"""A test state with no return in handler."""
... | 54 | 1,400 |
reflex | tests/units/middleware/conftest.py | .py | import pytest
from reflex_base.event import Event
from reflex.state import State
def create_event(name):
return Event(
name=name,
router_data={
"pathname": "/",
"query": {},
"token": "<token>",
"sid": "<sid>",
"headers": {},
... | 25 | 463 |
reflex | tests/units/reflex_site_shared/test_algolia.py | .py | """Tests for the shared keyword-only Algolia search."""
from pathlib import Path
from reflex_site_shared.components.algolia import AlgoliaSearch, Search
from reflex_site_shared.plugins import SharedSiteStylesPlugin
def test_algolia_search_uses_local_keyword_only_component() -> None:
"""Use the local Algolia UI ... | 619 | 27,565 |
reflex | tests/units/reflex_site_shared/test_docs_shell.py | .py | """Tests for the shared documentation shell."""
from pathlib import Path
import pytest
from reflex_site_shared.components.docs_shell import (
_docs_external_page_footer_memo,
docs_feedback_button_toc,
docs_left_sidebar,
docs_page_footer,
docs_right_sidebar,
docs_sidebar_category,
docs_side... | 232 | 7,411 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.