Class: HomeWorkChecker::ArchiveResult::PythonTestRun
- Defined in:
- lib/hw_checker/python_test_run.rb
Instance Method Summary collapse
-
#initialize(tmp_path, dirname) ⇒ PythonTestRun
constructor
A new instance of PythonTestRun.
- #perform ⇒ Object
Constructor Details
#initialize(tmp_path, dirname) ⇒ PythonTestRun
Returns a new instance of PythonTestRun.
4 5 6 7 8 |
# File 'lib/hw_checker/python_test_run.rb', line 4 def initialize(tmp_path, dirname) @work_path = "#{tmp_path}/#{dirname}/tests/application" raise DirectoryExistError, "Archive '#{dirname}' is invalid" unless Dir::exist?(@work_path) @passed = @failed = 0 end |
Instance Method Details
#perform ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/hw_checker/python_test_run.rb', line 10 def perform Dir.foreach(@work_path) do |p| next unless File.file?("#{@work_path}/#{p}") && File.extname(p) == '.py' && p != '__init__.py' `python #{@work_path}/#{p} > #{@work_path}/#{p}.tmp 2>&1` count_passed_failed("#{@work_path}/#{p}.tmp") end calc_percent_passed end |