Coverage for gpaw/test/setups/test_setup_basis_spec.py: 100%

20 statements  

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

1"""This test looks for differently named setups and basis sets to ascertain 

2that correct filenames are constructed. Generally speaking, the things 

3it looks for do not exist; we just verify the filenames. 

4""" 

5import pytest 

6from gpaw.basis_data import get_basis_name, parse_basis_name 

7from gpaw.setup import Setups 

8 

9 

10@pytest.mark.ci 

11@pytest.mark.parametrize( 

12 'setups, basis, refname', 

13 [({}, 'hello', 'Na.hello.basis'), 

14 ('hello', {}, 'Na.hello.LDA'), 

15 ('hello', 'dzp', 'Na.hello.dzp.basis'), 

16 ('hello', 'sz(dzp)', 'Na.hello.dzp.basis'), 

17 ('hello', 'world.dzp', 'Na.hello.world.dzp.basis'), 

18 ('hello', 'sz(world.dzp)', 'Na.hello.world.dzp.basis'), 

19 ('paw', 'world.dzp', 'Na.world.dzp.basis'), 

20 ('paw', 'sz(world.dzp)', 'Na.world.dzp.basis')]) 

21def test_setup_basis_spec(setups, basis, refname): 

22 with pytest.raises(FileNotFoundError) as err: 

23 Setups([11], setups, basis, 'LDA') 

24 msg = str(err) 

25 fname = msg.split('"')[1] 

26 assert fname == refname, fname 

27 

28 

29@pytest.mark.parametrize('basisname', 

30 'sz dz szp dzp dz2p dzdp tzqp dzsp'.split()) 

31def test_basis_something_something(basisname): 

32 zetacount, polarizationcount = parse_basis_name(basisname) 

33 normalized_name = get_basis_name(zetacount, polarizationcount) 

34 zetacount2, polarizationcount2 = parse_basis_name(normalized_name) 

35 assert zetacount == zetacount2 

36 assert polarizationcount == polarizationcount2 

37 if (polarizationcount < 2 and 

38 len(basisname) < 4 and basisname.isalpha()): 

39 assert normalized_name == basisname