seitime-frappe/frappe/tests
Sagar Vora 0dc3272530
Merge pull request #36106 from sagarvora/revert-ws-settings
chore: revert workspace settings and changes to script manager
2026-01-22 20:26:09 +05:30
..
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: update Content-Disposition header for binary as attachment 2026-01-22 17:30:43 +05:30
test_api_v2.py fix: add enqueue functionality for more than 20 docs 2026-01-09 19:24:38 +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 test: adjust param for get_user_input_stream 2024-01-29 15:18:08 +01:00
test_boot.py fix(test): fetch unseen notes 2025-04-21 19:12:46 +05:30
test_caching.py refactor: move whitelist_for_tests to common utils and apply to all test endpoints 2025-11-21 16:38:11 +05:30
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 feat(postgres): add unbuffered cursor in postgres (#35016) 2025-12-23 17:21:28 +05:30
test_db_query.py fix(qb): support reportview alias format 2026-01-06 19:30:14 +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 refactor!: deprecate older web view links (#35150) 2025-12-10 18:12:49 +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: commit to trigger sendmail 2025-12-17 16:36:06 +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 refactor!: Remove UUID Utils library (#36216) 2026-01-22 11:40:11 +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 refactor: seperate blogs into a seperate app (#32737) 2025-07-28 14:35:02 +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 fix(search): make QB DB-Aware when using Locate (#35796) 2026-01-12 12:06:28 +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 refactor: remove ignored params from call (#35185) 2025-12-11 12:47:11 +01: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 chore: formatting 2024-12-02 13:40:16 +05:30
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 chore: remove extra parameter form_doctype from search_link 2025-12-04 10:51:07 +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 fix(test): maintain sanity to avoid unexpected test failures in postgres 2026-01-03 13:54:27 +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 test: make test translation independent from real ones 2024-12-12 00:57:14 +01:00
test_twofactor.py test: avoid possible flake in OTP tests (#29214) 2025-01-17 07:32:17 +00:00
test_utils.py fix: ruff fixes 2025-12-22 21:06:48 +05:30
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 chore: revert workspace settings 2026-01-20 12:48:32 +05:30

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.