Coverage for gpaw/test/point_groups/test_cli.py: 100%

24 statements  

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

1"""Test point-group CLI.""" 

2import pytest 

3from ase.io.cube import write_cube 

4 

5from gpaw import GPAW 

6from gpaw.point_groups.cli import main 

7 

8 

9@pytest.mark.serial 

10def test_pg_cli(gpw_files, capsys): 

11 file = gpw_files['h2o_lcao'] 

12 main(f'C2v {file} -c O -b 0:4'.split()) 

13 out = capsys.readouterr().out 

14 lines = [line.split() for line in out.splitlines()] 

15 assert lines[1][1] == 'Yes' 

16 assert '-'.join(lines[n][4] for n in range(3, 7)) == 'A1-B2-A1-B1' 

17 

18 

19@pytest.mark.serial 

20def test_pg_cli_cube(gpw_files, capsys, in_tmp_dir): 

21 calc = GPAW(gpw_files['h2o_lcao']) 

22 wf = calc.get_pseudo_wave_function(0) 

23 cube = in_tmp_dir / 'h2o.cube' 

24 with cube.open('w') as fd: 

25 write_cube(fd, calc.atoms, wf) 

26 main(f'C2v {cube} -c O'.split()) 

27 out = capsys.readouterr().out 

28 lines = [line.split() for line in out.splitlines()] 

29 assert lines[1][1] == 'Yes' 

30 assert lines[3][4] == 'A1'