| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
import pytest |
| 6 |
from scalene.scalene_profiler import Scalene |
| 7 |
from threading import Lock |
| 8 |
|
| 9 |
|
| 10 |
Scalene._Scalene__invalidate_mutex = Lock() |
| 11 |
Scalene._Scalene__invalidate_queue = [] |
| 12 |
Scalene.last_profiled_tuple = lambda: ("filename.py", 123) |
| 13 |
Scalene.update_line = staticmethod(lambda: None) |
| 14 |
|
| 15 |
|
| 16 |
def test_update_profiled(): |
| 17 |
|
| 18 |
Scalene._Scalene__invalidate_queue.clear() |
| 19 |
|
| 20 |
|
| 21 |
Scalene.update_profiled() |
| 22 |
|
| 23 |
|
| 24 |
assert len(Scalene._Scalene__invalidate_queue) == 1 |
| 25 |
assert Scalene._Scalene__invalidate_queue[0] == ("filename.py", 123) |
| 26 |
|
| 27 |
|
| 28 |
Scalene._Scalene__invalidate_queue.clear() |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
def test_scalene_update_profiled(): |
| 33 |
test_update_profiled() |