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/units/reflex_site_shared/test_docs_api.py | .py | """Tests for shared documentation API tables."""
import pytest
from reflex_site_shared.components.docs_api import (
callable_api_reference,
docs_api_cell,
docs_api_row,
docs_api_table,
)
import reflex as rx
def documented_factory(
value: str,
*,
count: int = 3,
) -> dict[str, object]:
... | 115 | 3,488 |
reflex | tests/units/reflex_site_shared/test_plugins.py | .py | """Tests for shared site compiler plugins."""
from pathlib import Path
from types import SimpleNamespace
from reflex_site_shared.docs import DocsSiteConfig
from reflex_site_shared.plugins import DocsMarkdownPlugin, SharedSiteStylesPlugin
def test_shared_site_styles_plugin_includes_fontsource_css_by_default():
"... | 106 | 4,092 |
reflex | tests/units/reflex_site_shared/docs/test_imports.py | .py | """Import-boundary tests for the public documentation API."""
import subprocess
import sys
def test_template_and_public_docs_api_import_together():
"""Keep the public docs models independent from the template module."""
result = subprocess.run(
[
sys.executable,
"-c",
... | 29 | 933 |
reflex | tests/units/reflex_site_shared/docs/test_site.py | .py | """Tests for shared documentation route registration."""
from pathlib import Path
import pytest
from reflex_base.components.memo import MemoComponent
from reflex_site_shared.docs import (
DocsLayoutConfig,
DocsPage,
DocsSiteConfig,
NavigationItem,
build_docs_routes,
docs_sidebar_leaf,
regi... | 212 | 6,714 |
reflex | tests/units/reflex_site_shared/docs/test_navigation.py | .py | """Tests for shared documentation navigation."""
from pathlib import Path
from reflex_site_shared.docs import DocsPage, build_navigation, get_prev_next
def _page(route: str, title: str, relative_path: str) -> DocsPage:
"""Create a minimal page for navigation tests.
Returns:
The test page.
"""
... | 58 | 1,707 |
reflex | tests/units/reflex_site_shared/docs/test_markdown.py | .py | """Tests for the shared documentation Markdown renderer."""
from pathlib import Path
import pytest
from reflex_site_shared.docs.markdown import (
get_docgen_toc,
get_markdown_toc,
render_docgen_document,
render_inline_markdown,
render_markdown,
render_markdown_with_toc,
)
import reflex as rx
... | 308 | 8,323 |
reflex | tests/units/reflex_site_shared/docs/test_content.py | .py | """Tests for shared documentation content discovery."""
import re
from pathlib import Path
import pytest
from reflex_site_shared.docs import DocsSiteConfig, discover_docs
def test_discover_docs_builds_routes_and_metadata(tmp_path: Path):
"""Discover Markdown recursively and derive stable routes and metadata."""... | 114 | 4,129 |
reflex | tests/units/reflex_site_shared/utils/test_url.py | .py | """Unit tests for reflex_site_shared.utils.url."""
from types import SimpleNamespace
import pytest
from reflex_site_shared.utils.url import public_url
@pytest.fixture
def patch_config(monkeypatch):
"""Patch the config read by public_url with the given values.
Returns:
A function taking (deploy_url,... | 50 | 1,623 |
reflex | tests/units/reflex_site_shared/styles/test_fonts.py | .py | """Tests for shared font-family configuration."""
from reflex_site_shared import styles
from reflex_site_shared.styles import fonts
def test_shared_styles_use_configurable_font_variables():
"""Shared Python styles should honor consumer font-family overrides."""
assert styles.SANS == "var(--font-instrument-sa... | 18 | 727 |
reflex | tests/units/reflex_base/test_registry.py | .py | """Tests for RegistrationContext."""
import sys
from textwrap import dedent
import pytest
from reflex_base.config import Config, get_config, reload_config
from reflex_base.registry import RegisteredEventHandler, RegistrationContext
from reflex_base.utils.exceptions import ReflexRuntimeError, StateValueError
from ref... | 424 | 13,178 |
reflex | tests/units/reflex_base/event/test_context.py | .py | """Tests for EventContext."""
from unittest import mock
from reflex_base.event.context import EventContext
def test_fork_creates_child(mock_root_event_context: EventContext):
"""fork() creates a child context with a new txid and shared impls.
Args:
mock_root_event_context: The root event context fi... | 85 | 2,719 |
reflex | tests/units/reflex_base/event/processor/test_future.py | .py | """Tests for EventFuture."""
import asyncio
import pytest
from reflex_base.event.processor.future import EventFuture
@pytest.mark.asyncio
async def test_create_uses_running_loop(): # noqa: RUF029
"""EventFuture() defaults to the running event loop."""
running_loop = asyncio.get_running_loop()
f = Event... | 302 | 8,975 |
reflex | tests/units/reflex_base/event/processor/test_event_processor.py | .py | """Tests for EventProcessor lifecycle, task management, and error handling."""
import asyncio
import contextlib
from typing import Any
import pytest
from pytest_mock import MockerFixture
from reflex_base.event.context import EventContext
from reflex_base.event.processor.event_processor import (
EventProcessor,
... | 795 | 24,978 |
reflex | tests/units/reflex_base/event/processor/test_timeout.py | .py | """Tests for DrainTimeoutManager."""
import time
from reflex_base.event.processor.timeout import DrainTimeoutManager
def test_drain_timeout_no_timeout():
"""DrainTimeoutManager with no timeout returns 0."""
dtm = DrainTimeoutManager.with_timeout(None)
with dtm as remaining:
assert remaining == 0... | 30 | 839 |
reflex | tests/units/reflex_base/event/processor/test_base_state_processor.py | .py | """Tests for BaseStateEventProcessor, specifically the _rehydrate path."""
import traceback
from collections.abc import Mapping
from typing import Any
import pytest
import pytest_asyncio
from reflex_base.constants import CompileVars
from reflex_base.constants.state import FIELD_MARKER
from reflex_base.event.context i... | 217 | 7,209 |
reflex | tests/units/reflex_base/context/test_base.py | .py | """Tests for BaseContext."""
import dataclasses
import pytest
from reflex_base.context.base import BaseContext
@dataclasses.dataclass(frozen=True, kw_only=True, slots=True)
class _TestContext(BaseContext):
"""Minimal BaseContext subclass for unit testing."""
label: str = "test"
def test_get_without_set_r... | 95 | 2,823 |
reflex | tests/units/reflex_base/utils/test_types.py | .py | """Tests for reflex_base.utils.types."""
from reflex_base.utils.types import ASGIApp, Message, Receive, Scope, Send
from typing_extensions import TypeAliasType
def test_asgi_aliases_keep_their_names():
"""The ASGI type aliases are TypeAliasTypes so docs render them by name, not expanded."""
for alias in (Sco... | 17 | 602 |
reflex | tests/units/reflex_base/utils/pyi_generator/test_build_hashes.py | .py | """Regression test: building a package must not rewrite pyi_hashes.json.
The build hooks (``scripts/hatch_build.py`` for the main ``reflex`` package and
``hatch-reflex-pyi`` for the component subpackages) invoke the pyi_generator
module entrypoint to emit ``.pyi`` stubs into the wheel. They must NOT touch
``pyi_hashes... | 78 | 2,596 |
reflex | tests/units/reflex_base/utils/pyi_generator/test_unit.py | .py | """Unit tests for individual pyi_generator translation functions.
Tests smaller functions in isolation using "code in -> expected code out"
patterns. These complement the golden file regression tests by testing
edge cases in type resolution and AST generation directly.
"""
from __future__ import annotations
import a... | 461 | 12,467 |
reflex | tests/units/reflex_base/utils/pyi_generator/__main__.py | .py | """CLI entry point for pyi_generator regression tests.
Usage:
python -m tests.units.reflex_base.utils.pyi_generator --update
python -m tests.units.reflex_base.utils.pyi_generator --check
"""
from tests.units.reflex_base.utils.pyi_generator.test_regression import main
main()
| 11 | 286 |
reflex | tests/units/reflex_base/utils/pyi_generator/test_regression.py | .py | """Regression tests for pyi_generator.
Runs PyiGenerator.scan_all against a directory of curated Python files and
compares the generated .pyi stubs against a set of golden reference files.
Usage as CLI to regenerate golden files:
python -m tests.units.reflex_base.utils.pyi_generator --update
Usage as pytest:
... | 266 | 9,028 |
reflex | tests/units/reflex_base/utils/pyi_generator/test_hashes.py | .py | """Regression test: pyi_hashes.json must hash the final post-processed content.
``PyiGenerator.scan_all`` writes the raw ``ast.unparse`` output to disk and then
runs ``ruff format`` / ``ruff check --fix`` over the generated stubs. The hash
registry must be computed from the post-processed file contents: hashing the
in... | 72 | 2,107 |
reflex | tests/units/reflex_base/utils/pyi_generator/dataset/inheritance.py | .py | """Components with inheritance hierarchy.
This module tests:
- Props from parent classes appear in create() via MRO traversal
- Overridden props are not duplicated
- Multiple levels of inheritance
"""
from reflex_base.components.component import Component, field
from reflex_base.event import EventHandler, passthrough... | 40 | 1,117 |
reflex | tests/units/reflex_base/utils/pyi_generator/dataset/custom_create.py | .py | """Component with an explicitly defined create() method.
This module tests:
- Existing create() is regenerated (replaced with generated version)
- Decorator list from original create() is preserved
- Custom kwargs on create() are included
"""
from typing import Any
from reflex_base.components.component import Compon... | 39 | 1,082 |
reflex | tests/units/reflex_base/utils/pyi_generator/dataset/staticmethod_namespace.py | .py | """Namespace with staticmethod __call__ that is not Component.create.
This module tests:
- _generate_staticmethod_call_functiondef path
- Namespace __call__ with custom function (not wrapping .create)
- The fallback where __call__.__func__.__name__ != "create"
"""
from reflex_base.components.component import Componen... | 43 | 1,104 |
reflex | tests/units/reflex_base/utils/pyi_generator/dataset/module_level.py | .py | """Module with module-level functions, constants, and type aliases.
This module tests:
- Module-level function body blanking
- Module-level annotated assignments (value blanked)
- Module-level non-annotated assignments (removed)
- Type alias preservation
- Combined: component + module-level items
"""
from typing impo... | 49 | 1,152 |
reflex | tests/units/reflex_base/utils/pyi_generator/dataset/__init__.py | .py | """Test dataset for pyi_generator regression tests.
This package contains Python modules designed to exercise all translation
features of the pyi_generator. Each module targets specific code paths
in the generator.
"""
| 7 | 220 |
reflex | tests/units/reflex_base/utils/pyi_generator/dataset/namespace_component.py | .py | """Components using ComponentNamespace pattern.
This module tests:
- ComponentNamespace with __call__ = staticmethod(SomeComponent.create)
- Multiple components in the same module
- Namespace with staticmethod assignments
- Module-level namespace instance assignment
"""
from reflex_base.components.component import Co... | 44 | 1,107 |
reflex | tests/units/reflex_base/utils/pyi_generator/dataset/literal_types.py | .py | """Component with Literal type props.
This module tests:
- Literal type annotations on props
- Module-level Literal type aliases
- Var[Literal[...]] expansion (Var union with inner literal)
"""
from typing import Literal
from reflex_base.components.component import Component, field
from reflex_base.vars.base import ... | 32 | 893 |
reflex | tests/units/reflex_base/utils/pyi_generator/dataset/string_event_annotations.py | .py | """Component with string-based tuple return annotations on event handlers.
This module tests:
- figure_out_return_type with string-based "tuple[...]" annotation
- The string parsing path for event handler signatures
- Empty tuple[()], single arg tuple[str], multi-arg tuple[str, int]
"""
from reflex_base.components.co... | 64 | 1,553 |
reflex | tests/units/reflex_base/utils/pyi_generator/dataset/simple_component.py | .py | """A simple component with basic props.
This module tests:
- Basic component stub generation
- Props with various simple types (str, int, bool, float)
- Default event handlers inherited from Component
- Props with doc strings (via field(doc=...))
- Props with comment-based docs (# comment above prop)
- Props with inli... | 72 | 1,952 |
reflex | tests/units/reflex_base/utils/pyi_generator/dataset/classvar_and_private.py | .py | """Component with ClassVar, private attrs, and excluded props.
This module tests:
- ClassVar annotations are preserved (not turned into create() kwargs)
- Private annotated attributes (_foo) are removed from stubs
- EXCLUDED_PROPS (like tag, library, etc.) are not in create()
- Private methods are removed
- Non-annota... | 53 | 1,531 |
reflex | tests/units/reflex_base/utils/pyi_generator/dataset/var_types.py | .py | """Component with various Var[T] prop types and edge cases.
This module tests:
- Var[T] expansion: Var[str] -> Var[str] | str
- Var with Union args: Var[str | int] -> Var[str | int] | str | int
- Complex nested types: Var[list[str]], Var[dict[str, Any]], Var[list[dict[str, Any]]]
- Callable prop: Var[Callable[[], bool... | 51 | 1,693 |
reflex | tests/units/reflex_base/utils/pyi_generator/dataset/typed_event_handlers.py | .py | """Components with various event handler signatures.
This module tests:
- Custom event handlers with typed tuple returns
- passthrough_event_spec usage
- Multiple event specs (Sequence of specs)
- Event handlers with no args (no_args_event_spec)
- Event handler with multi-arg tuples
- String-based tuple return annotat... | 78 | 2,160 |
reflex | tests/units/reflex_base/utils/pyi_generator/dataset/sub_package/__init__.py | .py | """A sub-package with lazy loading.
This tests __init__.py stub generation with _SUBMOD_ATTRS.
"""
from reflex_base.utils import lazy_loader
_SUBMOD_ATTRS: dict[str, list[str]] = {
"widget": ["SubWidget"],
}
__getattr__, __dir__, __all__ = lazy_loader.attach(
__name__,
submod_attrs=_SUBMOD_ATTRS,
)
| 16 | 316 |
reflex | tests/units/reflex_base/utils/pyi_generator/dataset/sub_package/widget.py | .py | """A widget component for the sub_package.
This is a simple module providing a component for the __init__.py lazy loader test.
"""
from reflex_base.components.component import Component, field
from reflex_base.vars.base import Var
class SubWidget(Component):
"""A widget in the sub package."""
name: Var[str... | 14 | 350 |
reflex | tests/units/reflex_base/constants/test_installer.py | .py | """Tests for the frontend toolchain version constants."""
import pytest
from packaging import version
from reflex_base.constants.installer import Node, PackageJson
# Baselines declared by the pinned react-router release (its package.json
# `engines.node` and `peerDependencies.react`, plus the Vite floor from its
# re... | 55 | 2,141 |
reflex | tests/units/reflex_base/constants/test_base.py | .py | """Tests for reflex_base.constants.base."""
from __future__ import annotations
from typing import get_args
from reflex_base.constants.base import LITERAL_ENV, Env
def test_literal_env_matches_env_enum():
"""LITERAL_ENV must stay in sync with the Env enum values."""
assert set(get_args(LITERAL_ENV)) == {env... | 13 | 343 |
reflex | tests/units/reflex_base/vars/test_base.py | .py | """Tests for reflex_base.vars.base state metaclass field handling."""
import threading
from typing import Any
from reflex_base.utils.types import get_field_type
from reflex_base.vars.base import EvenMoreBasicBaseState, field
_MARKER_ATTR = "_marker"
def test_custom_field_attr_survives_annotated_rebuild():
"""A... | 90 | 2,944 |
reflex | tests/units/reflex_base/plugins/test_base.py | .py | """Tests for plugin base helpers."""
import pytest
from pytest_mock import MockerFixture
from reflex_base.plugins import Plugin, get_plugin
from reflex_base.utils.exceptions import ConfigError
class ConfiguredPlugin(Plugin):
"""Plugin type configured by the tests."""
class ConfiguredSubPlugin(ConfiguredPlugin)... | 73 | 2,198 |
reflex | tests/units/components/test_props.py | .py | from __future__ import annotations
import pytest
from reflex_base.components.props import NoExtrasAllowedProps, PropsBase
from reflex_base.event import (
EventChain,
EventHandler,
event,
no_args_event_spec,
passthrough_event_spec,
)
from reflex_base.utils.exceptions import InvalidPropValueError
fr... | 215 | 6,097 |
reflex | tests/units/components/test_component.py | .py | import copy
from contextlib import nullcontext
from dataclasses import dataclass
from typing import Any, ClassVar, TypedDict
import pytest
from reflex_base.components.component import Component, field
from reflex_base.constants import EventTriggers
from reflex_base.constants.state import FIELD_MARKER
from reflex_base.... | 2,344 | 70,751 |
reflex | tests/units/components/test_memo_cross_module.py | .py | """Cross-module ``@rx.memo`` collision tests driven through the real pipeline.
These exercise the full define -> register -> compile_memo_components -> page
compile -> validate_imports chain across REAL fixture modules (see
``memo_fixtures/``), the integration point that isolated per-module unit tests
missed. Each tes... | 200 | 7,039 |
reflex | tests/units/components/test_memo.py | .py | """Tests for rx.memo support."""
from __future__ import annotations
import inspect
from types import SimpleNamespace
from typing import Any, cast
from unittest.mock import patch
import pytest
from reflex_base.components.component import Component
from reflex_base.components.memo import (
_SPECS,
DEFAULT_MEMO... | 1,872 | 67,309 |
reflex | tests/units/components/test_component_state.py | .py | """Ensure that Components returned by ComponentState.create have independent State classes."""
import pytest
from reflex_base.utils.exceptions import ReflexRuntimeError
from reflex_components_core.base.bare import Bare
import reflex as rx
def test_component_state():
"""Create two components with independent sta... | 64 | 1,865 |
reflex | tests/units/components/test_tag.py | .py | import pytest
from reflex_base.components.tags import CondTag, Tag, tagless
from reflex_base.vars.base import LiteralVar, Var
@pytest.mark.parametrize(
("props", "test_props"),
[
({}, []),
({"key-hyphen": 1}, ['"key-hyphen":1']),
({"key": 1}, ["key:1"]),
({"key": "value"}, ['ke... | 130 | 3,400 |
reflex | tests/units/components/test_component_future_annotations.py | .py | from __future__ import annotations
from typing import Any
from reflex_base.components.component import Component
from reflex_base.event import EventHandler, input_event, no_args_event_spec
# This is a repeat of its namesake in test_component.py.
def test_custom_component_declare_event_handlers_in_fields():
clas... | 39 | 1,243 |
reflex | tests/units/components/lucide/test_icon.py | .py | import pytest
from reflex_base.utils import format
from reflex_base.vars.base import Var
from reflex_components_lucide.icon import (
LUCIDE_ICON_FILENAME_OVERRIDE,
LUCIDE_ICON_LIST,
LUCIDE_ICON_MAPPING_OVERRIDE,
LUCIDE_LIBRARY,
DynamicIcon,
Icon,
)
@pytest.mark.parametrize("tag", LUCIDE_ICON_L... | 120 | 4,188 |
reflex | tests/units/components/base/test_script.py | .py | """Test that element script renders correctly."""
import pytest
from reflex_components_core.base.script import Script
def test_script_inline():
"""Test inline scripts are rendered as children."""
component = Script.create("let x = 42")
render_dict = component.render()["children"][0]
assert render_dic... | 29 | 918 |
reflex | tests/units/components/base/test_bare.py | .py | import pytest
from reflex_base.vars.base import Var
from reflex_components_core.base.bare import Bare
STATE_VAR = Var(_js_expr="default_state.name")
@pytest.mark.parametrize(
("contents", "expected"),
[
("hello", '"hello"'),
("{}", '"{}"'),
(None, '""'),
(STATE_VAR, "default_s... | 26 | 620 |
reflex | tests/units/components/base/test_link.py | .py | from reflex_components_core.base.link import RawLink, ScriptTag
def test_raw_link():
raw_link = RawLink.create("https://example.com").render()
assert raw_link["name"] == '"link"'
assert raw_link["children"][0]["contents"] == '"https://example.com"'
def test_script_tag():
script_tag = ScriptTag.creat... | 14 | 496 |
reflex | tests/units/components/media/test_image.py | .py | import numpy as np
import PIL
import pytest
from PIL.Image import Image as Img
from reflex_base.utils.serializers import serialize, serialize_image
import reflex as rx
@pytest.fixture
def pil_image() -> Img:
"""Get an image.
Returns:
A random PIL image.
"""
rng = np.random.default_rng()
... | 38 | 995 |
reflex | tests/units/components/radix/test_callout.py | .py | from reflex_components_core.base.fragment import Fragment
from reflex_components_lucide.icon import Icon
from reflex_components_radix.themes.components.callout import (
Callout,
CalloutIcon,
CalloutRoot,
CalloutText,
)
def test_callout_create_without_icon():
component = Callout.create("You will ne... | 28 | 927 |
reflex | tests/units/components/radix/test_icon_button.py | .py | import pytest
from reflex_base.style import Style
from reflex_base.vars.base import LiteralVar
from reflex_components_lucide.icon import Icon
from reflex_components_radix.themes.components.icon_button import IconButton
def test_icon_button():
ib1 = IconButton.create("activity")
assert isinstance(ib1, IconButt... | 30 | 847 |
reflex | tests/units/components/radix/test_layout.py | .py | from reflex_components_radix.themes.layout.base import LayoutComponent
def test_layout_component():
lc = LayoutComponent.create()
assert isinstance(lc, LayoutComponent)
| 7 | 179 |
reflex | tests/units/components/graphing/test_plotly.py | .py | import numpy as np
import plotly.graph_objects as go
import pytest
from reflex_base.utils.serializers import serialize, serialize_figure
import reflex as rx
@pytest.fixture
def plotly_fig() -> go.Figure:
"""Get a plotly figure.
Returns:
A random plotly figure.
"""
# Generate random data.
... | 78 | 2,209 |
reflex | tests/units/components/graphing/test_recharts.py | .py | from reflex_components_recharts.charts import (
AreaChart,
BarChart,
LineChart,
PieChart,
RadarChart,
RadialBarChart,
ScatterChart,
)
from reflex_components_recharts.general import ResponsiveContainer
def test_area_chart():
ac = AreaChart.create()
assert isinstance(ac, ResponsiveCo... | 53 | 1,297 |
reflex | tests/units/components/recharts/test_polar.py | .py | from reflex_components_recharts import (
Pie,
PolarAngleAxis,
PolarGrid,
PolarRadiusAxis,
Radar,
RadialBar,
)
def test_pie():
pie = Pie.create().render()
assert pie["name"] == "RechartsPie"
def test_radar():
radar = Radar.create().render()
assert radar["name"] == "RechartsRad... | 39 | 859 |
reflex | tests/units/components/recharts/test_charts.py | .py | import pytest
from reflex_components_recharts.charts import (
AreaChart,
BarChart,
ComposedChart,
FunnelChart,
LineChart,
PieChart,
RadarChart,
RadialBarChart,
ScatterChart,
)
from reflex_components_recharts.general import Layer, Rectangle
CHART_CLASSES = [
AreaChart,
BarCha... | 33 | 718 |
reflex | tests/units/components/recharts/test_general.py | .py | from reflex_components_recharts import Layer, Rectangle
def test_layer():
layer = Layer.create().render()
assert layer["name"] == "RechartsLayer"
def test_layer_with_children():
layer = Layer.create(Rectangle.create()).render()
assert layer["name"] == "RechartsLayer"
assert layer["children"][0][... | 56 | 1,622 |
reflex | tests/units/components/recharts/test_cartesian.py | .py | from reflex_components_recharts import (
Area,
Bar,
Brush,
Line,
Scatter,
XAxis,
YAxis,
ZAxis,
)
def test_xaxis():
x_axis = XAxis.create("x").render()
assert x_axis["name"] == "RechartsXAxis"
def test_yaxis():
x_axis = YAxis.create("y").render()
assert x_axis["name"] ... | 51 | 934 |
reflex | tests/units/components/typography/test_markdown.py | .py | import pytest
from reflex_components_markdown.markdown import Markdown
import reflex as rx
@pytest.mark.parametrize(
("tag", "expected"),
[
("h1", "Heading"),
("h2", "Heading"),
("h3", "Heading"),
("h4", "Heading"),
("h5", "Heading"),
("h6", "Heading"),
... | 50 | 1,365 |
reflex | tests/units/components/datadisplay/test_code.py | .py | import pytest
from reflex_components_code.code import CodeBlock, Theme
import reflex as rx
@pytest.mark.parametrize(
("theme", "expected"),
[(Theme.one_light, "oneLight"), (Theme.one_dark, "oneDark")],
)
def test_code_light_dark_theme(theme, expected):
code_block = CodeBlock.create(theme=theme)
asse... | 59 | 2,109 |
reflex | tests/units/components/datadisplay/test_datatable.py | .py | import pandas as pd
import pytest
from reflex_base.constants.state import FIELD_MARKER
from reflex_base.utils.exceptions import UntypedComputedVarError
from reflex_base.utils.serializers import serialize, serialize_dataframe
from reflex_components_gridjs.datatable import DataTable
import reflex as rx
from reflex.utils... | 136 | 4,292 |
reflex | tests/units/components/datadisplay/test_shiki_code.py | .py | import pytest
from reflex_base.style import Style
from reflex_base.vars import Var
from reflex_base.vars.base import LiteralVar
from reflex_components_code.shiki_code_block import (
ShikiBaseTransformers,
ShikiCodeBlock,
ShikiHighLevelCodeBlock,
ShikiJsTransformer,
)
from reflex_components_core.el.eleme... | 175 | 6,137 |
reflex | tests/units/components/datadisplay/test_dataeditor.py | .py | from reflex_components_dataeditor.dataeditor import DataEditor
def test_dataeditor():
editor_wrapper = DataEditor.create().render()
editor = editor_wrapper["children"][0]
assert editor_wrapper["name"] == '"div"'
assert editor_wrapper["props"] == [
'css:({ ["width"] : "100%", ["height"] : "100%... | 12 | 374 |
reflex | tests/units/components/datadisplay/conftest.py | .py | """Data display component tests fixtures."""
import pandas as pd
import pytest
import reflex as rx
from reflex.state import BaseState
@pytest.fixture
def data_table_state(request):
"""Get a data table state.
Args:
request: The request.
Returns:
The data table state class.
"""
... | 90 | 1,602 |
reflex | tests/units/components/forms/test_form.py | .py | from typing import TypedDict
import pytest
from reflex_base.event import EventChain, prevent_default
from reflex_base.utils.exceptions import EventHandlerValueError
from reflex_base.vars.base import Var
from reflex_components_core.el.elements.forms import (
AUTO_HEIGHT_JS,
ENTER_KEY_SUBMIT_JS,
Input,
T... | 293 | 9,244 |
reflex | tests/units/components/core/test_colors.py | .py | import pytest
from reflex_base.constants.colors import Color
from reflex_base.constants.state import FIELD_MARKER
from reflex_base.vars.base import LiteralVar
from reflex_components_code.code import CodeBlock
import reflex as rx
class ColorState(rx.State):
"""Test color state."""
color: rx.Field[str] = rx.f... | 147 | 5,755 |
reflex | tests/units/components/core/test_foreach.py | .py | from dataclasses import dataclass
import pytest
from reflex_base.components.component import Component
from reflex_base.constants.state import FIELD_MARKER
from reflex_base.vars.number import NumberVar
from reflex_base.vars.sequence import ArrayVar
from reflex_components_core.core.foreach import (
Foreach,
For... | 328 | 9,734 |
reflex | tests/units/components/core/test_match.py | .py | import re
import pytest
from reflex_base.components.component import Component
from reflex_base.constants.state import FIELD_MARKER
from reflex_base.utils.exceptions import MatchTypeError
from reflex_base.vars.base import Var
from reflex_components_core.core.match import Match
import reflex as rx
from reflex.state im... | 321 | 11,840 |
reflex | tests/units/components/core/test_cond.py | .py | import json
from typing import Any, Literal, cast
import pytest
from reflex_base.components.component import Component
from reflex_base.constants.state import FIELD_MARKER
from reflex_base.utils.format import format_state_name
from reflex_base.vars.base import LiteralVar, Var, computed_var
from reflex_components_core.... | 214 | 7,029 |
reflex | tests/units/components/core/test_banner.py | .py | from reflex_components_core.core.banner import (
ConnectionBanner,
ConnectionModal,
ConnectionPulser,
WebsocketTargetURL,
)
from reflex_components_radix.themes.typography.text import Text
def test_websocket_target_url():
url = WebsocketTargetURL.create()
var_data = url._get_all_var_data()
... | 54 | 1,433 |
reflex | tests/units/components/core/test_debounce.py | .py | """Test that DebounceInput collapses nested forms."""
import pytest
from reflex_base.vars.base import LiteralVar, Var
from reflex_components_core.core.debounce import DEFAULT_DEBOUNCE_TIMEOUT
import reflex as rx
from reflex.state import BaseState
def test_create_no_child():
"""DebounceInput raises RuntimeError ... | 200 | 6,237 |
reflex | tests/units/components/core/test_responsive.py | .py | from reflex_components_core.core.responsive import (
desktop_only,
mobile_and_tablet,
mobile_only,
tablet_and_desktop,
tablet_only,
)
from reflex_components_core.el.elements.typography import Div
def test_mobile_only():
"""Test the mobile_only responsive component."""
component = mobile_on... | 39 | 1,038 |
reflex | tests/units/components/core/test_upload.py | .py | import asyncio
import io
import json
from typing import Any, cast
import pytest
from reflex_base.event import EventChain, EventHandler, EventSpec, parse_args_spec
from reflex_base.vars import VarData
from reflex_base.vars.base import LiteralVar, Var
from reflex_components_core.core._upload import (
UPLOAD_EVENT_AR... | 562 | 18,781 |
reflex | tests/units/components/core/test_html.py | .py | import pytest
from reflex_components_core.core.html import Html
from reflex.state import State
def test_html_no_children():
with pytest.raises(ValueError):
_ = Html.create()
def test_html_many_children():
with pytest.raises(ValueError):
_ = Html.create("foo", "bar")
def test_html_create()... | 44 | 1,217 |
reflex | tests/units/components/memo_fixtures/module_c.py | .py | """Cross-module memo fixture C.
``consumer`` references ``module_a.my_widget`` (a cross-module memo-to-memo
dependency), and this module also defines its own ``my_widget`` sharing the name
with ``module_a``/``module_b``. Together these cover a grouped memo file that
both imports another module's memo and exports its o... | 37 | 1,018 |
reflex | tests/units/components/memo_fixtures/module_b.py | .py | """Cross-module memo fixture B.
Mirrors ``module_a``'s memo names with different bodies so the two modules
produce distinct memos that share an export name.
"""
import reflex as rx
@rx.memo
def my_widget(title: rx.Var[str]) -> rx.Component:
"""Same name as ``module_a.my_widget`` but a different body.
Args:... | 34 | 694 |
reflex | tests/units/components/memo_fixtures/module_a.py | .py | """Cross-module memo fixture A.
Defines memos whose names also exist in ``module_b`` and ``module_c`` so the
same export name compiles in more than one module.
"""
import reflex as rx
@rx.memo
def my_widget(title: rx.Var[str]) -> rx.Component:
"""A component memo named the same as memos in the sibling fixtures.... | 34 | 697 |
reflex | tests/units/components/memo_fixtures/__init__.py | .py | """Real importable modules for cross-module ``@rx.memo`` collision tests.
Each submodule defines memos with names that intentionally clash across modules
so tests can exercise the full define -> register -> compile -> validate_imports
pipeline with genuine distinct ``fn.__module__`` values (not monkeypatched).
"""
| 7 | 317 |
reflex | tests/units/components/markdown/test_markdown.py | .py | import pytest
from reflex_base.components.component import Component
from reflex_base.components.memo import memo
from reflex_base.plugins import CompileContext, CompilerHooks, PageContext
from reflex_base.utils import memo_paths
from reflex_base.vars.base import Var
from reflex_components_code.code import CodeBlock
fr... | 269 | 10,657 |
reflex | tests/units/components/el/test_svg.py | .py | from reflex_components_core.el.elements.media import (
Circle,
Defs,
Ellipse,
G,
Line,
LinearGradient,
Marker,
Path,
Polygon,
RadialGradient,
Rect,
Stop,
Svg,
Text,
)
def test_circle():
circle = Circle.create().render()
assert circle["name"] == '"circle"... | 87 | 1,605 |
reflex | tests/units/compiler/test_dynamic_components_codegen.py | .py | """Code generation tests for dynamic components."""
from pathlib import Path
from reflex_base.utils import serializers
import reflex as rx
from reflex.state import State
STATE_JS_TEMPLATE = (
Path(__file__).parents[3]
/ "packages/reflex-base/src/reflex_base/.templates/web/utils/state.js"
)
def test_dynami... | 110 | 3,892 |
reflex | tests/units/compiler/test_stale_cleanup.py | .py | """Tests for the memo manifest-driven stale file cleanup."""
from __future__ import annotations
import json
from pathlib import Path
from unittest.mock import patch
import pytest
from reflex.compiler import utils as compiler_utils
@pytest.fixture
def fake_web_dir(tmp_path: Path):
"""Pretend tmp_path is the pr... | 170 | 5,566 |
reflex | tests/units/compiler/test_memoize_plugin.py | .py | # ruff: noqa: D101
import dataclasses
import re
from collections.abc import Callable
from pathlib import Path
from types import SimpleNamespace
from typing import Any, cast
import pytest
from reflex_base.components.component import Component
from reflex_base.components.component import field as component_field
from r... | 2,377 | 93,017 |
reflex | tests/units/compiler/test_compiler_utils.py | .py | from __future__ import annotations
import asyncio
import pytest
from reflex.compiler.utils import compile_state
from reflex.constants.state import FIELD_MARKER
from reflex.state import State
from reflex.vars.base import computed_var
class CompileStateState(State):
"""State fixture exercising async computed var... | 51 | 1,517 |
reflex | tests/units/compiler/test_plugins.py | .py | # ruff: noqa: D101, D102
import dataclasses
from collections.abc import Callable
from typing import Any
import pytest
from reflex_base.components.component import (
BaseComponent,
Component,
ComponentStyle,
field,
)
from reflex_base.constants.compiler import Hooks
from reflex_base.plugins import (
... | 1,258 | 40,376 |
reflex | tests/units/compiler/test_compiler.py | .py | import dataclasses
import importlib.util
import json
import os
from pathlib import Path, PureWindowsPath
import pytest
from pytest_mock import MockerFixture
from reflex_base import constants
from reflex_base.components.dynamic import bundle_library, reset_bundled_libraries
from reflex_base.constants.base import Litera... | 1,390 | 46,473 |
reflex | tests/units/compiler/test_state_js_template.py | .py | """Regression tests for the state.js frontend template."""
from pathlib import Path
STATE_JS_TEMPLATE = (
Path(__file__).parents[3]
/ "packages/reflex-base/src/reflex_base/.templates/web/utils/state.js"
)
def test_state_js_does_not_register_deprecated_unload_listener() -> None:
"""The template must not ... | 45 | 1,756 |
reflex | tests/units/reflex_components_internal/utils/test_twmerge.py | .py | from reflex_base.utils.imports import ImportVar
from reflex_base.vars import Var
from reflex_components_internal.utils.twmerge import cn
def test_cn_uses_clsx_and_tailwind_merge() -> None:
"""The class utility should flatten inputs before resolving Tailwind conflicts."""
merged = cn(
"px-2",
V... | 25 | 753 |
reflex | tests/units/states/mutation.py | .py | """Test states for mutable vars."""
import pytest
from reflex.state import BaseState
pytest.importorskip("pydantic")
import pydantic
class OtherBase(pydantic.BaseModel):
"""A BaseModel with a str field."""
bar: str = pydantic.Field(default="")
class CustomVar(pydantic.BaseModel):
"""A BaseModel wit... | 57 | 1,661 |
reflex | tests/units/states/__init__.py | .py | """Common rx.BaseState subclasses for use in tests."""
from reflex.state import BaseState
class GenState(BaseState):
"""A state with event handlers that generate multiple updates."""
value: int
def go(self, c: int):
"""Increment the value c times and update each time.
Args:
... | 23 | 494 |
reflex | tests/units/states/upload.py | .py | """Test states for upload-related tests."""
from pathlib import Path
from typing import BinaryIO
import reflex as rx
from reflex.state import BaseState, State
class UploadBaseState(BaseState):
"""The base state for uploading a file."""
class UploadState(BaseState):
"""The base state for uploading a file."... | 160 | 4,609 |
reflex | tests/units/plugins/test_sitemap.py | .py | """Unit tests for the sitemap plugin."""
import datetime
from unittest.mock import MagicMock, patch
from reflex_base.plugins.sitemap import (
SitemapLink,
generate_links_for_sitemap,
generate_xml,
)
import reflex as rx
from reflex.app import UnevaluatedPage
def test_generate_xml_empty_links():
"""T... | 707 | 21,094 |
reflex | tests/units/plugins/test_embed.py | .py | """Unit tests for the embed plugin."""
from __future__ import annotations
import re
from pathlib import Path
import pytest
from pytest_mock import MockerFixture
from reflex_base import constants
from reflex_base.plugins.embed import (
EmbedPlugin,
_inject_vite_dev_preview,
_mount_attrs_for_selector,
... | 273 | 8,744 |
reflex | tests/units/plugins/test_tailwind.py | .py | from pathlib import Path
import pytest
from reflex_base.plugins import tailwind_v3, tailwind_v4
@pytest.mark.parametrize("module", [tailwind_v3, tailwind_v4])
def test_compile_root_style_omits_radix_when_disabled(module):
"""Tailwind root styles should omit the Radix import when disabled."""
_, code = module... | 42 | 1,400 |
reflex | tests/units/assets/test_assets.py | .py | import copy
import hashlib
import io
import pickle
import shutil
from collections.abc import Generator
from pathlib import Path
from typing import cast
import pytest
import reflex as rx
import reflex.constants as constants
from reflex.assets import AssetPathStr, remove_stale_external_asset_symlinks
def _asset_hash(... | 439 | 14,562 |
reflex | tests/type_checking/vars.py | .py | """Inferred types for `reflex.vars` that are part of the public contract."""
from typing import Any, Literal
from typing_extensions import assert_type
from reflex.vars.base import Var
from reflex.vars.number import (
BooleanVar,
LiteralBooleanVar,
LiteralNumberVar,
NumberVar,
)
from reflex.vars.seque... | 41 | 1,713 |
reflex | scripts/run_lighthouse.py | .py | """Run the local Lighthouse benchmark with a fresh app build."""
from __future__ import annotations
import shutil
from pathlib import Path
from reflex_base import constants
from tests.integration.lighthouse_utils import (
LIGHTHOUSE_LANDING_APP_NAME,
run_landing_prod_lighthouse_benchmark,
)
def main() -> ... | 37 | 929 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.