4
4
import argparse
5
5
from vsh .scripts .kpoints import write_kpoints
6
6
7
- class TestWriteKpoints (unittest .TestCase ):
8
7
8
+ class TestWriteKpoints (unittest .TestCase ):
9
9
def print_expected_and_result (self ):
10
- args = argparse .Namespace (mesh_type = "monkhorst" , mesh = (4 , 4 , 4 ), input = None , output = None )
10
+ args = argparse .Namespace (
11
+ mesh_type = "monkhorst" , mesh = (4 , 4 , 4 ), input = None , output = None
12
+ )
11
13
expected_kpoints = Kpoints .monkhorst_automatic (kpts = (4 , 4 , 4 ))
12
14
13
- with patch ('builtins.print' ) as mock_print , patch ('pymatgen.io.vasp.inputs.Kpoints.write_file' ) as mock_write_file :
15
+ with patch ("builtins.print" ) as mock_print , patch (
16
+ "pymatgen.io.vasp.inputs.Kpoints.write_file"
17
+ ) as mock_write_file :
14
18
result = write_kpoints (args )
15
19
16
20
print (expected_kpoints )
17
21
print (result )
18
22
19
-
20
23
def test_write_kpoints_monkhorst (self ):
21
- args = argparse .Namespace (mesh_type = "monkhorst" , mesh = (4 , 4 , 4 ), input = None , output = None )
24
+ args = argparse .Namespace (
25
+ mesh_type = "monkhorst" , mesh = (4 , 4 , 4 ), input = None , output = None
26
+ )
22
27
expected_kpoints = Kpoints .monkhorst_automatic (kpts = (4 , 4 , 4 ))
23
28
24
- with patch ('builtins.print' ) as mock_print , patch ('pymatgen.io.vasp.inputs.Kpoints.write_file' ) as mock_write_file :
29
+ with patch ("builtins.print" ) as mock_print , patch (
30
+ "pymatgen.io.vasp.inputs.Kpoints.write_file"
31
+ ) as mock_write_file :
25
32
result = write_kpoints (args )
26
33
27
34
self .assertEqual (result , expected_kpoints )
28
35
mock_print .assert_not_called ()
29
36
mock_write_file .assert_not_called ()
30
37
31
38
def test_write_kpoints_gamma (self ):
32
- args = argparse .Namespace (mesh_type = "gamma" , mesh = (4 , 4 , 4 ), input = None , output = None )
39
+ args = argparse .Namespace (
40
+ mesh_type = "gamma" , mesh = (4 , 4 , 4 ), input = None , output = None
41
+ )
33
42
expected_kpoints = Kpoints .gamma_automatic (kpts = (4 , 4 , 4 ))
34
43
35
- with patch ('builtins.print' ) as mock_print , patch ('pymatgen.io.vasp.inputs.Kpoints.write_file' ) as mock_write_file :
44
+ with patch ("builtins.print" ) as mock_print , patch (
45
+ "pymatgen.io.vasp.inputs.Kpoints.write_file"
46
+ ) as mock_write_file :
36
47
result = write_kpoints (args )
37
48
38
49
self .assertEqual (result , expected_kpoints )
@@ -51,26 +62,35 @@ def test_write_kpoints_gamma(self):
51
62
# mock_write_file.assert_not_called()
52
63
53
64
def test_write_kpoints_no_output (self ):
54
- args = argparse .Namespace (mesh_type = "monkhorst" , mesh = (4 , 4 , 4 ), input = None , output = None )
65
+ args = argparse .Namespace (
66
+ mesh_type = "monkhorst" , mesh = (4 , 4 , 4 ), input = None , output = None
67
+ )
55
68
expected_kpoints = Kpoints .monkhorst_automatic (kpts = (4 , 4 , 4 ))
56
69
57
- with patch ('builtins.print' ) as mock_print , patch ('pymatgen.io.vasp.inputs.Kpoints.write_file' ) as mock_write_file :
70
+ with patch ("builtins.print" ) as mock_print , patch (
71
+ "pymatgen.io.vasp.inputs.Kpoints.write_file"
72
+ ) as mock_write_file :
58
73
result = write_kpoints (args )
59
74
60
75
self .assertEqual (result , expected_kpoints )
61
76
mock_print .assert_called_once_with (expected_kpoints )
62
77
mock_write_file .assert_not_called ()
63
78
64
79
def test_write_kpoints_with_output (self ):
65
- args = argparse .Namespace (mesh_type = "monkhorst" , mesh = (4 , 4 , 4 ), input = None , output = "KPOINTS" )
80
+ args = argparse .Namespace (
81
+ mesh_type = "monkhorst" , mesh = (4 , 4 , 4 ), input = None , output = "KPOINTS"
82
+ )
66
83
expected_kpoints = Kpoints .monkhorst_automatic (kpts = (4 , 4 , 4 ))
67
84
68
- with patch ('builtins.print' ) as mock_print , patch ('pymatgen.io.vasp.inputs.Kpoints.write_file' ) as mock_write_file :
85
+ with patch ("builtins.print" ) as mock_print , patch (
86
+ "pymatgen.io.vasp.inputs.Kpoints.write_file"
87
+ ) as mock_write_file :
69
88
result = write_kpoints (args )
70
89
71
90
self .assertEqual (result , expected_kpoints )
72
91
mock_print .assert_not_called ()
73
- mock_write_file .assert_called_once_with ('KPOINTS' )
92
+ mock_write_file .assert_called_once_with ("KPOINTS" )
93
+
74
94
75
- if __name__ == ' __main__' :
95
+ if __name__ == " __main__" :
76
96
unittest .main ()
0 commit comments