Coverage for gpaw/test/test_stdout.py: 73%
22 statements
« prev ^ index » next coverage.py v7.7.1, created at 2025-07-14 00:18 +0000
« prev ^ index » next coverage.py v7.7.1, created at 2025-07-14 00:18 +0000
1import sys
4def test_stdout():
5 class Out:
6 def write(self, x):
7 sys.__stdout__.write(x)
8 raise RuntimeError('not silent')
10 out, err = sys.stdout, sys.stderr
11 sys.stdout = sys.stderr = Out()
13 try:
14 from gpaw import GPAW, FermiDirac
15 from ase import Atom, Atoms
17 a = 5.0
18 h = 0.2
19 calc = GPAW(mode='fd', h=h, nbands=1, kpts=(1, 1, 1),
20 occupations=FermiDirac(width=1e-9),
21 xc='PBE',
22 txt=None)
23 hydrogen = Atoms([Atom('H', (a / 2, a / 2, a / 2), magmom=0)],
24 cell=(a, a, a),
25 calculator=calc)
26 hydrogen.get_forces()
27 except Exception:
28 sys.stdout = out
29 sys.stderr = err
30 raise
32 sys.stdout = out
33 sys.stderr = err