Coverage for gpaw/test/test_broadcast_imports.py: 100%

10 statements  

« prev     ^ index     » next       coverage.py v7.7.1, created at 2025-07-14 00:18 +0000

1import pytest 

2from gpaw._broadcast_imports import broadcast_imports 

3 

4# These tests would be better if we could find a way to call them 

5# without first executing gpaw.__init__ (e.g. with pytest-forked or 

6# something?). 

7# 

8# However at least the bad() test is useful because it specifies the 

9# fail behaviour which may not otherwise be exercised. 

10# 

11# Some day: Execute the imports in such a way that we can verify the 

12# module counts. 

13 

14 

15def test_bcast_imports_good(): 

16 with broadcast_imports: 

17 import gpaw.poisson as poisson_module 

18 assert poisson_module is not None 

19 

20 

21def test_bcast_imports_bad(): 

22 with broadcast_imports: 

23 with pytest.raises(ModuleNotFoundError): 

24 import gpaw.module_not_to_be_found # noqa