Esempio n. 1
0
def test_generates_svg():
    plugin = Profiling(True)
    plugin.profs = [sentinel.prof]
    with patch('pstats.Stats'):
        with patch('pipes.Template') as Template:
            plugin.pytest_sessionfinish(Mock(), Mock())
    assert any('gprof2dot' in args[0][0] for args in Template.return_value.append.call_args_list)
    assert Template.return_value.copy.called
Esempio n. 2
0
def test_combines_profs():
    plugin = Profiling(False)
    plugin.profs = [sentinel.prof0, sentinel.prof1]
    with patch('pstats.Stats') as Stats:
        plugin.pytest_sessionfinish(Mock(), Mock())
    Stats.assert_called_once_with(sentinel.prof0)
    Stats.return_value.add.assert_called_once_with(sentinel.prof1)
    assert Stats.return_value.dump_stats.called
Esempio n. 3
0
def test_writes_summary_svg():
    plugin = Profiling(True)
    plugin.profs = [sentinel.prof]
    terminalreporter = Mock()
    with patch('pstats.Stats'):
        with patch('pipes.Template'):
            plugin.pytest_sessionfinish(Mock(), Mock())
        plugin.pytest_terminal_summary(terminalreporter)
    assert 'SVG' in terminalreporter.write.call_args[0][0]
Esempio n. 4
0
def test_writes_summary():
    plugin = Profiling(False)
    plugin.profs = [sentinel.prof]
    terminalreporter, stats = Mock(), Mock()
    with patch('pstats.Stats', return_value=stats) as Stats:
        plugin.pytest_sessionfinish(Mock(), Mock())
        plugin.pytest_terminal_summary(terminalreporter)
    assert 'Profiling' in terminalreporter.write.call_args[0][0]
    assert Stats.called_with(stats, stream=terminalreporter)