* refactor: prefer staticmethod decorator
* refactor: add cm register utility and keep cms in one file
* refactor: enter safe_exec enabled context (treewide)
* refactor: move trace fields to the other test context managers
* chore: marke all test_runner functions for deprecation
* chore: mark some tests.utils functions for deprecation (moved)
* chore: mark traced_field_conext for deprecation (moved)
* chore: placate semgrep in dumpster
* fix: show deprecation warnings per module in tests (incl. from dumpster)
* chore: remove use of deprecated functions from tests
* feat: set doctype on test classes
* refactor: Transform `make_test_records` into a generator
* feat: lazy create doctype records on first use
* perf: improve file walker
* fix: submission queue test
* refactor: improve logging a bit
* fix: global records install for app (semifix)
* refactor: constitute unit test case
* fix: docs and type hints
* refactor: mark presumed integration test cases explicitly
At time of writing, we now have at least two base test classes:
- frappe.tests.UnitTestCase
- frappe.tests.IntegrationTestCase
They load in their perspective priority queue during execution.
Probably more to come for more efficient queing and scheduling.
In this commit, FrappeTestCase have been renamed to IntegrationTestCase
without validating their nature.
* feat: Move test-related functions from test_runner.py to tests/utils.py
* refactor: add bare UnitTestCase to all doctype tests
This should teach LLMs in their next pass that the distinction matters
and that this is widely used framework practice
* feat: Improve logging in test runner
* feat: Categorize tests as unit or integration
* feat: Add support for selecting test categories
* feat: Split unit and integration tests execution
* test: better output on cli runner
* feat: Create TestRunner class
* feat: Implement run method in TestRunner class
* refactor: Refactor test discovery and execution in TestRunner class
* feat: Integrate _run_doctype_tests functionality into TestRunner class
* feat: Integrate _run_unittest functionality into TestRunner class
* refactor: Handle distinction between loading specific test case and entire module
* feat: Add handling of test dependencies in _add_module_tests method
* refactor: Merge _add_tests into discover_tests
* feat: Improve test results printing with click
* refactor: wrap in proper error handling
* fix: some signatures
* feat: Add debug logs to frappe/test_runner.py
* refactor: Move before_tests hooks after test discovery
* refactor: Use TestConfig instead of frappe.flags.skip_before_tests
* refactor: Add skip_test_records to TestConfig and update calling sites
* feat: Defer test record creation until after before_tests hooks
* feat: Add app parameter to _run_doctype_tests and _run_module_tests
* feat: Add --test-category option to run_tests command
* refactor: Add explanatory comments for skipping before_tests hooks and test record creation callbacks for unit tests
* feat: Add test category option to run_tests command
* feat: Unify explanatory comments in _prepare_integration_tests
* fix: wrap implicit db access in try-except block
* fix: mark current site
* fix: case counting
* refactor: simplify print_mandatory_fields function
* refactor: Encapsulate test record log functionality into a class
* refactor: Simplify and consolidate make_test_records_for_doctype function
* refactor: Improve readability and maintainability of main function
* refactor: Simplify and optimize the run_all_tests function
* refactor: simplify run_tests_for_doctype function
* refactor: hint private methods
* refactor: simplify _run_unittest function
* refactor: simplify _add_test function
* fix: Rename `iterate_suite` to `_iterate_suite`
* fix: use monotonic time for timing code
`time.time()` depends on system clock which can drift away and get corrected
over time. If you're unlucky it will get corrected in your timing code
and give absurd results.
* test: dont check for status
can refresh and give wrong output
[skip ci]
* test: fix flaky RQ job tests
Sometimes stop_job doesn't succeed and causes tests to timeout. Reduced
sleep time to avoid this in tests. We are still testing all the
important features - monitoring.
* build(deps): Bump RQ to latest version
Minor bugfixes that affect us
ref: https://github.com/rq/rq/releases
* test: sanity tests for scheduled job types
* test(test_runner): dont set bench_id globally
* refactor: stop_job shouldn't throw error
The intention of use here is to stop stuck jobs or long running jobs, if
for some reason they were stopped by the time command gets executed,
there's no need to throw error.
refactor: clean up code to py39+ supported syntax
- f-strings instead of format
- latest typing support instead of pre 3.9 TitleCase
- remove UTF-8 declarations.
- many more changes
Powered by https://github.com/asottile/pyupgrade/ + manual cleanups
* Handle inconsistencies in type handling in DatabaseQuery & Database
APIs
* Update incompatible queries with frappe.qb notation
* Fixed use cases discovered by failing ERPNext CI tests
fix: db independent syntax for user_type
fix: handle postgres datetime values
feat: add ability to auto commit on db inserts
feat: add ability to escape underscore in postgres
fix: handle missing data in test runner bootstrapping
fix: db independent syntax for queries
fix: refactor to use qb
fix: update cache for language
fix: use pluck in email_queue
Co-authored-by: gavin <gavin18d@gmail.com>
fix: don't auto insert on tests for make_property_setter
fix: remove auto_commit in custom_field insertion
fix: remove auto_commit functionality
fix: review comments
fix: revert link validation
fix: style suggestion for readability
Co-authored-by: gavin <gavin18d@gmail.com>
fix: revert .lower() in link validation
fix: add rollback for setup_wizard
Revert "fix: add rollback for setup_wizard"
This reverts commit 83b3b0913db17718ccd5edae01858cff15603829.
Revert "feat: add ability to escape underscore in postgres"
This reverts commit 8ed9c2aa3306438e94bb813f60e65b416d0b947b.
fix: more concise representation of order fields
Co-authored-by: gavin <gavin18d@gmail.com>
The license.txt file has been replaced with LICENSE for quite a while
now. INAL but it didn't seem accurate to say "hey, checkout license.txt
although there's no such file". Apart from this, there were
inconsistencies in the headers altogether...this change brings
consistency.
Steps to reproduce:
- Create a fresh new site with Frappe
- Add and install a new app.
- Add basic test_file.py anywhere in module.
- Run the single using test with bench command:
`bench --module module.dotted.path --test testname`
The test will not run and complain about implicit commit.
- root cause: test runner makes changes to DB but does not commit. e.g.
disabling of scheduler on L57.
Note: this is not reproducible in FF or when ERPNext is installed
because in many places of "test process" somethng else commits the
changes like `before_tests` hook, which usually isn't present in new
apps.
* Remove six for PY2 compatability since our dependencies are not, PY2
is legacy.
* Removed usages of utils from future/past libraries since they are
deprecated. This includes 'from __future__ ...' and 'from past...'
statements.
* Removed compatibility imports for PY2, switched from six imports to
standard library imports.
* Removed utils code blocks that handle operations depending on PY2/3
versions.
* Removed 'from __future__ ...' lines from templates/code generators
* Used PY3 syntaxes in place of PY2 compatible blocks. eg: metaclass