@@ -318,6 +318,71 @@ def test_no_test_sources(tmp_path, capfd):
318318 ) in capfd .readouterr ().err
319319
320320
321+ @needs_emulator
322+ def test_environment_markers (tmp_path ):
323+ project = new_c_project ()
324+ test_filename = "test_environment_markers.py"
325+ project .files [test_filename ] = dedent (
326+ """\
327+ import pytest
328+
329+ def test_android():
330+ import certifi
331+
332+ def test_not_android():
333+ try:
334+ import platformdirs
335+ except ImportError:
336+ pass
337+ else:
338+ pytest.fail("`platformdirs` should not have been installed")
339+ """
340+ )
341+ project .generate (tmp_path )
342+
343+ cibuildwheel_run (
344+ tmp_path ,
345+ add_env = {
346+ ** cp313_env ,
347+ "CIBW_TEST_COMMAND" : f"python -m pytest { test_filename } " ,
348+ "CIBW_TEST_SOURCES" : test_filename ,
349+ "CIBW_TEST_REQUIRES" : " " .join (
350+ [
351+ "pytest" ,
352+ "certifi;sys_platform=='android'" ,
353+ "platformdirs;sys_platform!='android'" ,
354+ ]
355+ ),
356+ },
357+ )
358+
359+
360+ @needs_emulator
361+ def test_verbosity (tmp_path , capfd ):
362+ new_c_project ().generate (tmp_path )
363+ test_env = {
364+ ** cp313_env ,
365+ "CIBW_TEST_COMMAND" : """python -c 'print("Hello world")'""" ,
366+ }
367+ verbose_lines = [
368+ "> Task :app:packageDebug" , # Gradle
369+ "I/TestRunner: run started: 1 tests" , # Logcat
370+ ]
371+
372+ cibuildwheel_run (tmp_path , add_env = test_env )
373+ stdout = capfd .readouterr ().out
374+ for line in verbose_lines :
375+ assert line not in stdout
376+
377+ cibuildwheel_run (
378+ tmp_path ,
379+ add_env = {** test_env , "CIBW_BUILD_VERBOSITY" : "1" },
380+ )
381+ stdout = capfd .readouterr ().out
382+ for line in verbose_lines :
383+ assert line in stdout
384+
385+
321386@needs_emulator
322387def test_api_level (tmp_path , capfd ):
323388 project = new_c_project ()
0 commit comments