test_from_file_encoding() — langchain Function Reference
Architecture documentation for the test_from_file_encoding() function in test_prompt.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 868ff224_c6e6_f412_78b1_aa371af28ba1["test_from_file_encoding()"] af1b998b_a7bf_9d5c_32ef_bab507a6bee3["test_prompt.py"] 868ff224_c6e6_f412_78b1_aa371af28ba1 -->|defined in| af1b998b_a7bf_9d5c_32ef_bab507a6bee3 style 868ff224_c6e6_f412_78b1_aa371af28ba1 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/tests/unit_tests/prompts/test_prompt.py lines 30–48
def test_from_file_encoding() -> None:
"""Test that we can load a template from a file with a non utf-8 encoding."""
template = "This is a {foo} test with special character €."
input_variables = ["foo"]
# First write to a file using CP-1252 encoding.
with NamedTemporaryFile(delete=True, mode="w", encoding="cp1252") as f:
f.write(template)
f.flush()
file_name = f.name
# Now read from the file using CP-1252 encoding and test
prompt = PromptTemplate.from_file(file_name, encoding="cp1252")
assert prompt.template == template
assert prompt.input_variables == input_variables
# Now read from the file using UTF-8 encoding and test
with pytest.raises(UnicodeDecodeError):
PromptTemplate.from_file(file_name, encoding="utf-8")
Domain
Subdomains
Source
Frequently Asked Questions
What does test_from_file_encoding() do?
test_from_file_encoding() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/prompts/test_prompt.py.
Where is test_from_file_encoding() defined?
test_from_file_encoding() is defined in libs/core/tests/unit_tests/prompts/test_prompt.py at line 30.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free