Coverage for tests/unit_tests/scons/test_apio_env.py: 100%

23 statements  

« prev     ^ index     » next       coverage.py v7.11.0, created at 2025-11-06 10:20 +0000

1""" 

2Tests of the scons ApioEnv. 

3""" 

4 

5from tests.unit_tests.scons.testing import make_test_apio_env 

6from tests.conftest import ApioRunner 

7from apio.scons.apio_env import ApioEnv 

8 

9 

10def test_env_is_debug(apio_runner: ApioRunner): 

11 """Tests the env handling of the in_debug var.""" 

12 

13 with apio_runner.in_sandbox(): 

14 

15 env: ApioEnv = make_test_apio_env(debug_level=2) 

16 assert env.is_debug(1) 

17 assert env.is_debug(2) 

18 assert not env.is_debug(3) 

19 

20 env: ApioEnv = make_test_apio_env(debug_level=0) 

21 assert not env.is_debug(1) 

22 assert not env.is_debug(2) 

23 assert not env.is_debug(3) 

24 

25 

26def test_env_platform_id(): 

27 """Tests the env handling of the platform_id param.""" 

28 

29 # -- Test with a non windows platform id. 

30 env = make_test_apio_env(platform_id="darwin-arm64", is_windows=False) 

31 assert not env.is_windows 

32 

33 # -- Test with a windows platform id. 

34 env = make_test_apio_env(platform_id="windows-amd64", is_windows=True) 

35 assert env.is_windows 

36 

37 

38def test_targeting(): 

39 """Test the targeting() method.""" 

40 

41 # -- The test env targets 'build'. 

42 apio_env = make_test_apio_env() 

43 

44 assert apio_env.targeting("build") 

45 assert apio_env.targeting("upload", "build") 

46 assert not apio_env.targeting("upload")