codeflash/tests
Kevin Turcios 0312c37631 feat: extract imported class definitions for testgen context
When generating tests, the LLM now receives class definitions for
types imported from project modules. This helps the LLM understand:
- Constructor signatures (avoiding incorrect argument guessing)
- Base classes (e.g., abstract classes that can't be instantiated)
- Class structure for creating proper test instances

Previously, the LLM only saw import statements like:
  from mypackage.elements import Element

Now it also sees the actual class definition with constructor details.

Changes:
- Add get_imported_class_definitions() to extract class definitions
  from project modules referenced in import statements
- Integrate into get_code_optimization_context() to include extracted
  classes in testgen context
- Gracefully handle token limits by dropping class definitions if needed
- Add 4 unit tests covering extraction, deduplication, and filtering
2026-01-07 16:09:29 -05:00
..
benchmarks created benchmarks for codeflash, modified codeflash-optimize to use codeflash --benchmark 2025-04-15 21:18:59 -04:00
code_utils tests done, ready to review 2025-10-13 18:28:06 -07:00
scripts Merge branch 'main' into no-gen-test-arg 2025-12-30 09:09:28 -08:00
__init__.py Move aiservice to django/aiservice 2024-01-02 16:55:24 -08:00
mymodule.py WIP diffbehavior support, up to and including full replacement module code for each optimization candidate. Remaining: writing module code to each git worktree, running diffbehavior vs each candidate worktree, collecting results. TODO comment driven programming at its finest. 2024-10-30 01:30:10 -07:00
test_add_needed_imports_from_module.py exact test 2025-09-26 18:04:14 -07:00
test_add_runtime_comments.py few missing things 2025-09-26 16:25:28 -07:00
test_async_function_discovery.py CF-900 allow async optimizations by default (#938) 2025-11-23 16:36:13 -05:00
test_async_run_and_parse_tests.py remove test_framework from pyproject.toml (#955) 2025-12-09 02:53:08 -08:00
test_async_wrapper_sqlite_validation.py no windows for now 2025-09-30 01:12:12 +00:00
test_cmd_init.py remove test_framework from pyproject.toml (#955) 2025-12-09 02:53:08 -08:00
test_code_context_extractor.py feat: extract imported class definitions for testgen context 2026-01-07 16:09:29 -05:00
test_code_deduplication.py deduplicate optimizations better 2025-09-13 16:03:52 -07:00
test_code_extractor_none_aliases_exact.py litellm fix 2025-10-11 00:06:41 -07:00
test_code_replacement.py handle new added classes 2025-11-11 16:20:11 +02:00
test_code_utils.py use pytest as the execution engine for all tests (#951) 2025-12-06 22:40:25 -06:00
test_codeflash_capture.py handle test class methods for the test diff 2025-12-01 16:48:23 +02:00
test_codeflash_checkpoint.py Add tests 2025-04-29 18:07:42 -07:00
test_codeflash_trace_decorator.py work on new replay_test logic 2025-04-09 17:18:22 -07:00
test_comparator.py comparator fix 2026-01-02 11:07:45 -08:00
test_critic.py remove test_framework from pyproject.toml (#955) 2025-12-09 02:53:08 -08:00
test_existing_tests_source_for.py ready to merge 2025-08-11 12:07:01 -07:00
test_file_to_no_of_tests.py crosscheck 2025-11-12 17:19:54 -08:00
test_formatter.py None not supported for formatter commands 2025-11-11 22:02:25 -05:00
test_function_dependencies.py fix: unit tests 2025-09-25 04:10:25 +03:00
test_function_discovery.py reinsert 2025-07-29 23:49:22 -07:00
test_function_ranker.py tracer improvements (#970) 2025-12-19 03:32:49 +00:00
test_get_code.py reinsert 2025-07-29 23:49:22 -07:00
test_get_helper_code.py fix test for windows 2025-10-08 02:32:03 +03:00
test_get_read_only_code.py Implemented testgen context retrieval. Context retrieved is the union of read-writable code and read-only code. Did some refactors to remove code_to_optimize_with_helpers, and updated tests. 2025-03-05 16:40:23 -08:00
test_get_read_writable_code.py Implemented testgen context retrieval. Context retrieved is the union of read-writable code and read-only code. Did some refactors to remove code_to_optimize_with_helpers, and updated tests. 2025-03-05 16:40:23 -08:00
test_get_testgen_code.py Implemented testgen context retrieval. Context retrieved is the union of read-writable code and read-only code. Did some refactors to remove code_to_optimize_with_helpers, and updated tests. 2025-03-05 16:40:23 -08:00
test_git_utils.py Add tests for handling detached HEAD state in Git operations 2025-12-18 14:05:04 +02:00
test_humanize_time.py ready to merge 2025-06-18 14:40:48 -07:00
test_instrument_all_and_run.py Merge branch 'main' of github.com:codeflash-ai/codeflash into feat/feedback-loop-for-unmatched-test-results 2025-12-11 16:59:38 +02:00
test_instrument_async_tests.py remove test_framework from pyproject.toml (#955) 2025-12-09 02:53:08 -08:00
test_instrument_codeflash_capture.py reinsert 2025-07-29 23:49:22 -07:00
test_instrument_codeflash_trace.py handled edge case for instrumenting codeflash trace 2025-04-09 17:19:20 -07:00
test_instrument_line_profiler.py update expectations here 2026-01-01 12:34:40 -05:00
test_instrument_tests.py remove test_framework from pyproject.toml (#955) 2025-12-09 02:53:08 -08:00
test_instrumentation_run_results_aiservice.py fix tests 2025-11-27 19:51:55 +02:00
test_lru_cache_clear.py few manual fixes 2025-02-28 20:24:35 -08:00
test_merge_test_results.py organized imports 2025-03-28 15:26:27 -07:00
test_merge_tests.py update the test-key format 2024-01-22 16:26:32 -08:00
test_multi_file_code_replacement.py add global assignments after the imports 2025-08-22 15:52:15 +03:00
test_parse_pytest_test_failures.py tests: parse test output 2025-12-17 16:06:36 +02:00
test_pickle_patcher.py Merge branch 'main' of github.com:codeflash-ai/codeflash into feat/feedback-loop-for-unmatched-test-results 2025-12-11 16:59:38 +02:00
test_pytest_plugin_deterministic_patches.py update tests 2025-10-28 23:05:26 -07:00
test_remove_functions_from_generated_tests.py first commit 2025-06-05 19:31:01 -07:00
test_remove_unused_definitions.py fix: track base class dependencies in unused definition remover 2026-01-01 02:24:51 -05:00
test_shell_utils.py saving the API key correctly for windows PowerShell (#940) 2025-11-26 02:02:31 -05:00
test_static_analysis.py move things around & more efficient passes 2025-06-07 11:30:29 -07:00
test_test_runner.py use pytest as the execution engine for all tests (#951) 2025-12-06 22:40:25 -06:00
test_trace_benchmarks.py windows shenanigans 2025-09-28 05:49:36 +00:00
test_tracer.py tracer improvements (#970) 2025-12-19 03:32:49 +00:00
test_unit_test_discovery.py type hints not well supported in 3.9 2025-11-21 11:51:06 -08:00
test_unused_helper_revert.py fix 2025-10-21 14:12:06 -07:00
test_validate_python_code.py fix validation error for python code 2025-12-11 19:11:57 +02:00
test_version_check.py fix tests 2025-09-11 14:31:58 -07:00
test_worktree.py CF-815: check if branch is pushed for --file as well (#883) 2025-11-17 20:37:30 +00:00