@@ -144,21 +144,29 @@ def test_factory_and_platform_constructor_are_compatible_types() -> None:
144144
145145
146146def test_deprecated_factory_accepts_documented_kwargs () -> None :
147- os_ = platform .system ().lower ()
148- kwargs : dict [str , object ] = {"compression_level" : 1 , "with_cursor" : True }
147+ """Verify that kwargs are accepted, even if not relevant.
148+
149+ All 10.1-documented kwargs were accepted on every platform, even
150+ if only meaningful on one. Verify that still works via the
151+ deprecated factory.
152+ """
153+ kwargs = {
154+ "compression_level" : 1 ,
155+ "with_cursor" : True ,
156+ "max_displays" : 1 ,
157+ "display" : getenv ("DISPLAY" ), # None on non-Linux
158+ }
159+
160+ with pytest .warns (DeprecationWarning ) as caught : # noqa: PT030 (we test the contents below)
161+ context = mss .mss (** kwargs )
149162
150- if os_ == "linux" :
151- display = getenv ("DISPLAY" )
152- assert display
153- kwargs ["display" ] = display
154- elif os_ == "darwin" :
155- kwargs ["max_displays" ] = 1
156- elif os_ != "windows" :
157- msg = f"Unsupported platform for compatibility test: { os_ !r} "
158- raise AssertionError (msg )
163+ expected_messages = {"mss.mss is deprecated" , "ignored on this platform" }
159164
160- with pytest .warns (DeprecationWarning , match = r"^mss\.mss is deprecated" ):
161- context = mss .mss (** kwargs )
165+ assert any ("mss.mss is deprecated" in str (w .message ) for w in caught )
166+ assert any ("ignored on this platform" in str (w .message ) for w in caught )
167+ assert all (any (expected in str (w .message ) for expected in expected_messages ) for w in caught ), (
168+ f"Unexpected warnings: { [str (w .message ) for w in caught ]} "
169+ )
162170
163171 with context as sct :
164172 assert isinstance (sct , MSSBase )
0 commit comments