seitime-frappe/frappe/tests
Ankush Menat 657b1eb50c
fix!: Restrict allowed HTML in msgprints (#37399)
Co-authored-by: AarDG10 <aarol.dsouza@gmail.com>
2026-02-23 11:49:15 +00:00
..
classes test: Dump log for any stuck test 2025-12-05 13:16:24 +05:30
data test: Add test for lazy_import 2022-08-11 23:53:21 +05:30
utils fix: ruff fixes 2025-12-22 21:06:48 +05:30
__init__.py refactor: organize test contextmanagers (#28041) 2024-10-09 02:09:19 +02:00
README.md refactor: Structure frappe.test.utils (green to green) (#28038) 2024-10-08 15:10:24 +00:00
test_api.py fix: add type hints to whitelisted methods 4 (#37204) 2026-02-20 14:53:08 +05:30
test_api_v2.py fix: add type hints to whitelisted methods 4 (#37204) 2026-02-20 14:53:08 +05:30
test_assign.py refactor: unit vs integration treewide (#27992) 2024-10-06 09:43:36 +00:00
test_auth.py fix: ruff fixes 2025-12-22 21:06:48 +05:30
test_background_jobs.py perf: faster local attr lookup 2025-03-12 14:03:36 +05:30
test_base_document.py fix: minor improvements to extended class logic 2025-09-09 11:15:17 +05:30
test_boilerplate.py fix(DX): Add patches folder when generating new app boilerplate (#37352) 2026-02-23 11:08:20 +05:30
test_boot.py fix(test): fetch unseen notes 2025-04-21 19:12:46 +05:30
test_caching.py test: Reset mock the right way (#37045) 2026-02-16 06:27:01 +00:00
test_child_table.py refactor: unit vs integration treewide (#27992) 2024-10-06 09:43:36 +00:00
test_client.py fix!: disallow setting link values not matching filters 2026-01-10 13:25:35 +05:30
test_client_cache.py fix: Avoid mixing client cache and redis_wrapper 2025-01-14 15:20:47 +05:30
test_config.py refactor: unit vs integration treewide (#27992) 2024-10-06 09:43:36 +00:00
test_cors.py refactor: unit vs integration treewide (#27992) 2024-10-06 09:43:36 +00:00
test_dashboard_connections.py refactor: unit vs integration treewide (#27992) 2024-10-06 09:43:36 +00:00
test_db.py fix(db): support list of fields in get_value method when cache is True (#37050) 2026-02-16 20:28:38 +05:30
test_db_query.py Merge pull request #35318 from AarDG10/add-custom-hook 2026-02-17 23:05:32 +05:30
test_db_update.py perf(postgres): skip unnecessary migrations due to type mismatch (#34784) 2025-12-29 18:29:22 +05:30
test_defaults.py refactor: seperate blogs into a seperate app (#32737) 2025-07-28 14:35:02 +05:30
test_deferred_insert.py refactor: unit vs integration treewide (#27992) 2024-10-06 09:43:36 +00:00
test_docstatus.py chore: fix typo in new DocStatus constant 2025-03-05 08:29:47 +05:30
test_document.py test: remove unused var 2026-01-23 14:45:23 +05:30
test_document_locks.py refactor: unit vs integration treewide (#27992) 2024-10-06 09:43:36 +00:00
test_domainification.py chore: clean desktop icon controller 2025-12-18 14:20:00 +05:30
test_dynamic_links.py refactor: unit vs integration treewide (#27992) 2024-10-06 09:43:36 +00:00
test_email.py test: fix test to suit the changes 2026-02-22 11:35:19 +05:30
test_exporter_fixtures.py refactor: unit vs integration treewide (#27992) 2024-10-06 09:43:36 +00:00
test_fixture_import.py fix: clear cache and prevent data access after DocType deletion (#34307) 2025-10-10 08:00:51 +00:00
test_fmt_datetime.py refactor: unit vs integration treewide (#27992) 2024-10-06 09:43:36 +00:00
test_fmt_money.py refactor: unit vs integration treewide (#27992) 2024-10-06 09:43:36 +00:00
test_form_load.py refactor: seperate blogs into a seperate app (#32737) 2025-07-28 14:35:02 +05:30
test_formatter.py refactor: unit vs integration treewide (#27992) 2024-10-06 09:43:36 +00:00
test_frappe_client.py refactor: support new function style 2025-11-19 21:15:57 +05:30
test_global_search.py fix: global search text, remove hooks 2025-06-18 16:23:36 +05:30
test_goal.py refactor: unit vs integration treewide (#27992) 2024-10-06 09:43:36 +00:00
test_helpers.py refactor: seperate blogs into a seperate app (#32737) 2025-07-28 14:35:02 +05:30
test_hooks.py refactor(treewide): ruff format 2025-09-26 13:16:43 +05:30
test_linked_with.py refactor: unit vs integration treewide (#27992) 2024-10-06 09:43:36 +00:00
test_listview.py refactor: unit vs integration treewide (#27992) 2024-10-06 09:43:36 +00:00
test_local_proxy.py perf: faster LocalProxy (#29181) 2025-01-20 12:49:55 +00:00
test_model_utils.py refactor: unit vs integration treewide (#27992) 2024-10-06 09:43:36 +00:00
test_modules.py fix(test): note customization yields tuple with 3 values 2026-01-02 18:50:24 +05:30
test_monitor.py refactor: unit vs integration treewide (#27992) 2024-10-06 09:43:36 +00:00
test_naming.py feat: Enhance autoname functionality (#36827) 2026-02-07 06:22:28 +00:00
test_nestedset.py feat(qb_query)!: return query object if requested 2025-12-09 11:39:48 +05:30
test_non_nullable_docfield.py refactor: unit vs integration treewide (#27992) 2024-10-06 09:43:36 +00:00
test_oauth20.py fix: OAuth2 absolute authorize, access token and api urls (#34266) 2025-10-09 16:47:38 +05:30
test_password.py refactor: unit vs integration treewide (#27992) 2024-10-06 09:43:36 +00:00
test_password_strength.py test: retry flaky password_strength test thrice 2023-12-20 13:57:48 +05:30
test_patches.py refactor(treewide): ruff format 2025-09-26 13:16:43 +05:30
test_pdf.py refactor: unit vs integration treewide (#27992) 2024-10-06 09:43:36 +00:00
test_perf.py chore: drop some version checks 2025-12-22 21:06:48 +05:30
test_permissions.py test: allow default fields in query 2026-02-02 15:32:39 +05:30
test_printview.py refactor: unit vs integration treewide (#27992) 2024-10-06 09:43:36 +00:00
test_project_meta.py chore: temporarily increase __init__.py length allowance. (#33803) 2025-08-26 12:20:58 +00:00
test_query.py Merge pull request #35940 from AarDG10/fix-orderby-pg 2026-02-22 13:09:43 +05:30
test_query_builder.py test: skip DB-specific tests using new unimplemented_for decorator (#34749) 2025-11-28 06:51:45 +00:00
test_query_report.py fix(system console): allow read-only queries in system console (#36652) 2026-02-05 11:39:10 +00:00
test_rate_limiter.py fix: Round of rate limit to seconds (#31674) 2025-03-12 10:52:42 +00:00
test_rating.py refactor: unit vs integration treewide (#27992) 2024-10-06 09:43:36 +00:00
test_recorder.py refactor: Structure frappe.test.utils (green to green) (#28038) 2024-10-08 15:10:24 +00:00
test_redis.py refactor: unit vs integration treewide (#27992) 2024-10-06 09:43:36 +00:00
test_removing_orphans.py fix: add test for removing orphan entity 2025-12-08 16:44:13 +05:30
test_rename_doc.py fix: add type hints to whitelisted methods 3 (#37149) 2026-02-20 06:50:19 +00:00
test_reportview.py feat: allow users to export report in background (#33861) 2025-09-05 14:34:55 +00:00
test_safe_exec.py fix: make shared jenv thread-safe 2025-01-15 11:53:00 +05:30
test_scheduler.py fix: granular status in system health report 2025-02-25 10:38:25 +05:30
test_search.py fix: add type hints to whitelisted methods 4 (#37204) 2026-02-20 14:53:08 +05:30
test_seen.py refactor: unit vs integration treewide (#27992) 2024-10-06 09:43:36 +00:00
test_sequence.py refactor: unit vs integration treewide (#27992) 2024-10-06 09:43:36 +00:00
test_sitemap.py refactor: seperate blogs into a seperate app (#32737) 2025-07-28 14:35:02 +05:30
test_sqlite_search.py refactor: resumable indexing without max_runtime 2026-02-06 15:05:52 +05:30
test_test_utils.py refactor: Rename get_settings -> get_single_value (#32840) 2025-06-09 04:20:29 +00:00
test_trace.py feat: global frappe.in_test flag (#32960) 2025-06-17 19:19:31 +05:30
test_translate.py fix: sync translations from crowdin (#36437) 2026-01-30 06:31:20 +00:00
test_twofactor.py refactor: removed usage of cmd for login (#36801) 2026-02-16 14:09:48 +05:30
test_utils.py fix!: Restrict allowed HTML in msgprints (#37399) 2026-02-23 11:49:15 +00:00
test_virtual_doctype.py refactor: unit vs integration treewide (#27992) 2024-10-06 09:43:36 +00:00
test_webform.py fix!: Remove badly written default portal list views (#35182) 2025-12-14 07:11:45 +00:00
test_website.py feat: move /app to /desk 2025-11-14 23:05:13 +05:30
translation_test_file.txt feat: allow splitting _() function call on multiple lines 2022-03-26 16:18:35 +05:30
ui_test_helpers.py Merge pull request #37318 from AarDG10/fix-types 2026-02-20 12:11:16 +00:00

Frappe Test Framework

This README provides an overview of the test case framework available in Frappe. These utilities are designed to facilitate efficient and effective testing of Frappe applications.

This is different from the frappe.testing module which houses the discovery and runner infrastructure for CLI and CI.

Directory Structure

The test framework is organized into the following structure:

frappe/tests/
├── classes/
│   ├── context_managers.py
│   ├── unit_test_case.py
│   └── ...
├── utils/
│   ├── generators.py
│   └── ...
├── test_api.py
├── test_child_table.py
└── ...

Key Components

  1. Test case classes (UnitTestCase and IntegrationTestCase)
  2. Framework and class specific context managers
  3. Utility functions and generators
  4. Specific test modules for various Frappe components

Test Case Classes

UnitTestCase (classes/unit_test_case.py)

Import convention: from frappe.tests import UnitTestCase

This class extends unittest.TestCase and provides additional utilities specific to the Frappe framework. It's designed for testing individual components or functions in isolation.

Key features include:

  • Custom assertions for Frappe-specific comparisons
  • Utilities for HTML and SQL normalization
  • Context managers for user switching and time freezing

IntegrationTestCase (classes/integration_test_case.py)

Import convention: from frappe.tests import IntegrationTestCase

This class extends UnitTestCase and is designed for integration testing. It provides features for:

  • Automatic site and connection setup
  • Automatic test records loading
  • Automatic reset of thread locals
  • Context managers that depend on a site connection
  • Asserts that depend on a site connection

For a detailed list of context managers, please refer to the code.

Utility Functions and Generators (utils/generators.py)

This module contains utility functions for generating test records and managing test data.

Specific Test Modules

Various test modules (e.g., test_api.py, test_document.py) contain tests for specific Frappe core components and functionalities.

Note that Document tests are collocated alongside each Document module.

Usage

To use these test utilities in your Frappe application tests, you can inherit from the appropriate test case class:

from frappe.tests import UnitTestCase

class MyTestCase(UnitTestCase):
    def test_something(self):
        # Your test code here
        pass

Contributing

When adding new test utilities or modifying existing ones:

  1. Place them in the appropriate directory based on their function.
  2. Update this README to reflect any significant changes in the framework structure or usage.
  3. Ensure that your changes follow the existing coding style and conventions.

Remember to always refer to the actual code for the most up-to-date and detailed information on available methods and their usage.