Class: LearnTest::Strategies::Pytest
Instance Attribute Summary
#options, #runner
Instance Method Summary
collapse
#argv, #configure, #die, #initialize, #learn_oauth_token, #push_results?, #run_install, #user_id, #username
Instance Method Details
#check_dependencies ⇒ Object
#cleanup ⇒ Object
58
59
60
|
# File 'lib/learn_test/strategies/pytest.rb', line 58
def cleanup
FileUtils.rm('.results.xml')
end
|
#detect ⇒ Object
13
14
15
|
# File 'lib/learn_test/strategies/pytest.rb', line 13
def detect
test_files.count > 0
end
|
#output ⇒ Object
25
26
27
|
# File 'lib/learn_test/strategies/pytest.rb', line 25
def output
@output ||= Crack::XML.parse(File.read('.results.xml'))['testsuite']
end
|
#results ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/learn_test/strategies/pytest.rb', line 34
def results
failed_count = output['failures'].to_i + output['errors'].to_i
skipped_count = output['skips'].to_i
passed_count = output['tests'].to_i - failed_count - skipped_count
{
username: username,
github_user_id: user_id,
learn_oauth_token: learn_oauth_token,
repo_name: runner.repo,
build: {
test_suite: [{
framework: 'pytest',
formatted_output: output.to_json,
duration: output['time']
}]
},
examples: output['tests'].to_i,
passing_count: passed_count,
pending_count: skipped_count,
failure_count: failed_count,
failure_descriptions: concat_failure_descriptions
}
end
|
#run ⇒ Object
21
22
23
|
# File 'lib/learn_test/strategies/pytest.rb', line 21
def run
system("python -m pytest #{options[:argv].join(' ')} --junitxml='./.results.xml'")
end
|
#service_endpoint ⇒ Object
9
10
11
|
# File 'lib/learn_test/strategies/pytest.rb', line 9
def service_endpoint
'/e/flatiron_pytest'
end
|
#test_files ⇒ Object
29
30
31
32
|
# File 'lib/learn_test/strategies/pytest.rb', line 29
def test_files
@test_files ||= Dir.glob('**/test_*.py') + Dir.glob('**/*_test.py')
end
|