class CommitLive::Strategies::PythonUnittest
Public Instance Methods
cleanup()
click to toggle source
# File lib/commit-live/tests/strategies/python-test.rb, line 52 def cleanup if File.exists?('.results.json') FileUtils.rm('.results.json') end end
detect()
click to toggle source
# File lib/commit-live/tests/strategies/python-test.rb, line 7 def detect files.any? {|f| f.match(/.*.py$/) } end
files()
click to toggle source
# File lib/commit-live/tests/strategies/python-test.rb, line 11 def files @files ||= Dir.entries('.') end
print_results()
click to toggle source
# File lib/commit-live/tests/strategies/python-test.rb, line 19 def print_results if File.exists?('.results.json') rows = [] totalPassed = 0 totalFailed = 0 test_results = results columns = ['Test Case', 'Status'] test_results["results"].each do |value| newRow = [value["name"], value["type"]] isErrorOrFail = value['type'] == 'failure' || value['type'] == 'error' totalFailed += 1 if isErrorOrFail newRow << value['message'] if isErrorOrFail totalPassed += 1 if value['type'] == 'success' rows << newRow end if totalFailed > 0 columns << 'Message' end table = Terminal::Table.new do |t| t.headings = columns t.rows = rows t.style = { :all_separators => true } end puts table puts "Total Passed: #{totalPassed}" puts "Total Failed: #{totalFailed}" end end
results()
click to toggle source
# File lib/commit-live/tests/strategies/python-test.rb, line 48 def results @output ||= Oj.load(File.read('.results.json'), mode: :compat) end
run(dir)
click to toggle source
# File lib/commit-live/tests/strategies/python-test.rb, line 15 def run(dir) system("nosetests #{dir} --verbose --with-json --json-file=\"./.results.json\" > /dev/null 2>&1") end