| 1 |
import pytest |
| 2 |
from rpython.rlib import rvmprof |
| 3 |
from rpython.rlib.rvmprof.test.support import FakeVMProf, fakevmprof |
| 4 |
|
| 5 |
class TestFakeVMProf(object): |
| 6 |
|
| 7 |
def test_sampling(self): |
| 8 |
fake = FakeVMProf() |
| 9 |
assert not fake.is_sampling_enabled |
| 10 |
|
| 11 |
fake.start_sampling() |
| 12 |
assert fake.is_sampling_enabled |
| 13 |
|
| 14 |
fake.stop_sampling() |
| 15 |
fake.stop_sampling() |
| 16 |
assert not fake.is_sampling_enabled |
| 17 |
|
| 18 |
fake.start_sampling() |
| 19 |
assert not fake.is_sampling_enabled |
| 20 |
fake.start_sampling() |
| 21 |
assert fake.is_sampling_enabled |
| 22 |
|
| 23 |
pytest.raises(AssertionError, "fake.start_sampling()") |
| 24 |
|
| 25 |
def test_check_status(self): |
| 26 |
fake = FakeVMProf() |
| 27 |
fake.stop_sampling() |
| 28 |
pytest.raises(ValueError, "fake.check_status()") |
| 29 |
|
| 30 |
|
| 31 |
class TestFixture(object): |
| 32 |
|
| 33 |
def test_fixture(self, fakevmprof): |
| 34 |
assert isinstance(fakevmprof, FakeVMProf) |
| 35 |
assert rvmprof._get_vmprof() is fakevmprof |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
rvmprof.start_sampling() |
| 40 |
assert fakevmprof.is_sampling_enabled |
| 41 |
rvmprof.stop_sampling() |
| 42 |
assert not fakevmprof.is_sampling_enabled |