|
1 | 1 | """Test elements.py.""" |
| 2 | + |
2 | 3 | # pylint: disable=import-error, wrong-import-position, unused-argument, line-too-long |
3 | 4 |
|
4 | 5 | import sys |
|
10 | 11 |
|
11 | 12 |
|
12 | 13 | def test_element_print_out(capfd): |
13 | | - """Test element_print_out()""" |
| 14 | + """Test element_print_out() produces complete output""" |
14 | 15 | element_print_out() |
15 | 16 | captured = capfd.readouterr() |
16 | 17 | expected_output = ( |
@@ -106,3 +107,63 @@ def test_element_print_out(capfd): |
106 | 107 | "Lanthanide Elements\n" |
107 | 108 | ) |
108 | 109 | assert captured.out == expected_output |
| 110 | + |
| 111 | + |
| 112 | +def test_element_print_out_returns_none(): |
| 113 | + """Test that element_print_out() returns None""" |
| 114 | + result = element_print_out() |
| 115 | + assert result is None |
| 116 | + |
| 117 | + |
| 118 | +def test_element_print_out_contains_hydrogen(capfd): |
| 119 | + """Test that output contains Hydrogen""" |
| 120 | + element_print_out() |
| 121 | + captured = capfd.readouterr() |
| 122 | + assert "Hydrogen" in captured.out |
| 123 | + assert "(H)" in captured.out |
| 124 | + |
| 125 | + |
| 126 | +def test_element_print_out_contains_all_groups(capfd): |
| 127 | + """Test that output contains all element groups""" |
| 128 | + element_print_out() |
| 129 | + captured = capfd.readouterr() |
| 130 | + |
| 131 | + # Check all major groups are present |
| 132 | + assert "Alkali Metals - Group 1" in captured.out |
| 133 | + assert "Alkaline Earth Metals - Group 2" in captured.out |
| 134 | + assert "Transition Elements - Groups 3-12" in captured.out |
| 135 | + assert "Boron Elements - Group 13" in captured.out |
| 136 | + assert "Carbon Elements - Group 14" in captured.out |
| 137 | + assert "Nitrogen Elements - Group 15" in captured.out |
| 138 | + assert "Oxygen Elements - Group 16" in captured.out |
| 139 | + assert "Halogen Elements - Group 17" in captured.out |
| 140 | + assert "Noble Gases - Group 18" in captured.out |
| 141 | + assert "Lanthanide Elements" in captured.out |
| 142 | + |
| 143 | + |
| 144 | +def test_element_print_out_contains_noble_gases(capfd): |
| 145 | + """Test that output contains all noble gases""" |
| 146 | + element_print_out() |
| 147 | + captured = capfd.readouterr() |
| 148 | + |
| 149 | + # Check noble gases |
| 150 | + assert "Helium (He)" in captured.out |
| 151 | + assert "Neon (Ne)" in captured.out |
| 152 | + assert "Argon (Ar)" in captured.out |
| 153 | + assert "Krypton (Kr)" in captured.out |
| 154 | + assert "Xenon (Xe)" in captured.out |
| 155 | + assert "Radon (Rn)" in captured.out |
| 156 | + |
| 157 | + |
| 158 | +def test_element_print_out_contains_alkali_metals(capfd): |
| 159 | + """Test that output contains all alkali metals""" |
| 160 | + element_print_out() |
| 161 | + captured = capfd.readouterr() |
| 162 | + |
| 163 | + # Check alkali metals |
| 164 | + assert "Lithium (Li)" in captured.out |
| 165 | + assert "Sodium (Na)" in captured.out |
| 166 | + assert "Potassium (K)" in captured.out |
| 167 | + assert "Rubidium (Rb)" in captured.out |
| 168 | + assert "Cesium (Cs)" in captured.out |
| 169 | + assert "Francium (Fr)" in captured.out |
0 commit comments