Class: RubyLLM::Toolbox::Tools::PythonTests
- Includes:
- ToolchainHelpers
- Defined in:
- lib/ruby_llm/toolbox/tools/python_tests.rb
Overview
EXEC. Runs the project’s Python tests (pytest or unittest) from fs_root and returns the output with a pass/fail headline. A failing suite is a normal result, not a tool error. Runs in the project environment, so a virtualenv/installed deps resolve as they would in a shell.
Constant Summary collapse
- FRAMEWORKS =
%w[pytest unittest].freeze
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods included from ToolchainHelpers
#gemfile?, #jail_relative, #run_in_project, #toolchain_output
Methods inherited from Base
#call, exec_tool!, exec_tool?, #initialize, #name
Constructor Details
This class inherits a constructor from RubyLLM::Toolbox::Base
Instance Method Details
#execute(path: nil, framework: "pytest") ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/ruby_llm/toolbox/tools/python_tests.rb', line 30 def execute(path: nil, framework: "pytest") fw = framework.to_s.strip.downcase fw = "pytest" if fw.empty? return error("unknown framework: #{fw} (use #{FRAMEWORKS.join(', ')})", code: :bad_framework) unless FRAMEWORKS.include?(fw) rel = jail_relative(path) out, err, status = run_in_project(args_for(fw, rel), use_bundle: false) toolchain_output(out, err, status, pass_label: summarize(out, err, "TESTS PASSED"), fail_label: summarize(out, err, "TESTS FAILED")) rescue Safety::PathJail::Jailbreak => e error(e., code: :path_denied) rescue CommandMissing => e error("#{e.} is not available (is it installed in the project env?)", code: :unavailable) end |