Class: HomeWorkChecker::TestRunStat::PythonTestRun

Inherits:
Object
  • Object
show all
Defined in:
lib/hw_checker/python_test_run.rb

Instance Method Summary collapse

Constructor Details

#initialize(tmp_path, dirname) ⇒ PythonTestRun

Returns a new instance of PythonTestRun.



4
5
6
7
# File 'lib/hw_checker/python_test_run.rb', line 4

def initialize(tmp_path, dirname)
  @tmp_path, @dirname= tmp_path, dirname
  @passed = @failed = 0
end

Instance Method Details

#performObject



9
10
11
12
13
14
15
16
# File 'lib/hw_checker/python_test_run.rb', line 9

def perform
  Dir.foreach("#{@tmp_path}/#{@dirname}/tests/application") do |p|
    next unless File.file?("#{@tmp_path}/#{@dirname}/tests/application/#{p}") && File.extname(p) == '.py' && p != '__init__.py'
    `python #{@tmp_path}/#{@dirname}/tests/application/#{p} > #{@tmp_path}/#{@dirname}/tests/application/#{p}.tmp 2>&1`
    count_passed_failed("#{@tmp_path}/#{@dirname}/tests/application/#{p}.tmp")
  end
  calc_percent_passed
end