Home / Function/ test_rst_code_splitter() — langchain Function Reference

test_rst_code_splitter() — langchain Function Reference

Architecture documentation for the test_rst_code_splitter() function in test_text_splitters.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  6f5fa8fc_506b_50bb_af4a_9df22994db1e["test_rst_code_splitter()"]
  6d6b8ad4_1cfe_fbb0_e58e_76a50487c135["test_text_splitters.py"]
  6f5fa8fc_506b_50bb_af4a_9df22994db1e -->|defined in| 6d6b8ad4_1cfe_fbb0_e58e_76a50487c135
  style 6f5fa8fc_506b_50bb_af4a_9df22994db1e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/text-splitters/tests/unit_tests/test_text_splitters.py lines 686–735

def test_rst_code_splitter() -> None:
    splitter = RecursiveCharacterTextSplitter.from_language(
        Language.RST, chunk_size=CHUNK_SIZE, chunk_overlap=0
    )
    code = """
Sample Document
===============

Section
-------

This is the content of the section.

Lists
-----

- Item 1
- Item 2
- Item 3

Comment
*******
Not a comment

.. This is a comment
    """
    chunks = splitter.split_text(code)
    assert chunks == [
        "Sample Document",
        "===============",
        "Section",
        "-------",
        "This is the",
        "content of the",
        "section.",
        "Lists",
        "-----",
        "- Item 1",
        "- Item 2",
        "- Item 3",
        "Comment",
        "*******",
        "Not a comment",
        ".. This is a",
        "comment",
    ]
    # Special test for special characters
    code = "harry\n***\nbabylon is"
    chunks = splitter.split_text(code)
    assert chunks == ["harry", "***\nbabylon is"]

Domain

Subdomains

Frequently Asked Questions

What does test_rst_code_splitter() do?
test_rst_code_splitter() is a function in the langchain codebase, defined in libs/text-splitters/tests/unit_tests/test_text_splitters.py.
Where is test_rst_code_splitter() defined?
test_rst_code_splitter() is defined in libs/text-splitters/tests/unit_tests/test_text_splitters.py at line 686.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free