Skip to content

Commit 7f98b6a

Browse files
committed
Adjustments following previous commit
- Fixed the type annotation of `srcdc_dict`. - Removed obsolete comment in `test_windows.py`. - Fixed `PytestDeprecationWarning: --no-print-logs is deprecated and scheduled for removal in pytest 6.0.` - Fixed Sourcery issues in `test_windows.py`.
1 parent 80aa06e commit 7f98b6a

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

mss/tests/test_windows.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,32 +27,30 @@ def test_region_caching():
2727
"""The region to grab is cached, ensure this is well-done."""
2828
from mss.windows import MSS
2929

30-
# Same sizes but different positions
31-
region1 = {"top": 0, "left": 0, "width": 200, "height": 200}
32-
region2 = {"top": 200, "left": 200, "width": 200, "height": 200}
33-
3430
with mss.mss() as sct:
3531
# Reset the current BMP
3632
if MSS.bmp:
3733
sct.gdi32.DeleteObject(MSS.bmp)
3834
MSS.bmp = None
3935

4036
# Grab the area 1
37+
region1 = {"top": 0, "left": 0, "width": 200, "height": 200}
4138
sct.grab(region1)
42-
bmp1 = MSS.bmp
39+
bmp1 = id(MSS.bmp)
4340

4441
# Grab the area 2, the cached BMP is used
42+
# Same sizes but different positions
43+
region2 = {"top": 200, "left": 200, "width": 200, "height": 200}
4544
sct.grab(region2)
46-
bmp2 = MSS.bmp
47-
assert bmp1 is bmp2
45+
bmp2 = id(MSS.bmp)
46+
assert bmp1 == bmp2
4847

4948
# Grab the area 2 again, the cached BMP is used
5049
sct.grab(region2)
51-
assert bmp2 is MSS.bmp
50+
assert bmp2 == id(MSS.bmp)
5251

5352

5453
def run_child_thread(loops):
55-
"""Every loop will take about 1 second."""
5654
for _ in range(loops):
5755
with mss.mss() as sct:
5856
sct.grab(sct.monitors[1])

mss/windows.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
from .exception import ScreenShotError
2828

2929
if TYPE_CHECKING:
30-
from typing import Any # noqa
30+
from typing import Any, Dict # noqa
3131

3232
from .models import Monitor, Monitors # noqa
3333
from .screenshot import ScreenShot # noqa
@@ -76,7 +76,7 @@ class MSS(MSSBase):
7676
memdc = None
7777

7878
# A dict to maintain *srcdc* values created by multiple threads.
79-
srcdc_dict = {}
79+
srcdc_dict = {} # type: Dict[int, Any]
8080

8181
# A threading lock to lock resources(bmp/memdc/srcdc) inside .grab() method.
8282
_lock = threading.Lock()

setup.cfg

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,5 @@ addopts =
5151
--showlocals
5252
--strict
5353
--failed-first
54-
--no-print-logs
5554
-r fE
5655
-v

0 commit comments

Comments
 (0)