File: test_element_types.py

package info (click to toggle)
python-periodictable 2.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,152 kB
  • sloc: python: 14,808; makefile: 103; sh: 92; javascript: 7
file content (31 lines) | stat: -rw-r--r-- 923 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import periodictable
from periodictable.core import Element, Isotope

# Test symbol access
c_element: Element = periodictable.C
fe_element: Element = periodictable.Fe
u_element: Element = periodictable.U

# Test name access
carbon: Element = periodictable.carbon
iron: Element = periodictable.iron
uranium: Element = periodictable.uranium

# Test that we can access element properties
mass: float = periodictable.C.mass
symbol: str = periodictable.Fe.symbol
number: int = periodictable.U.number

# Test special cases
deuterium: Isotope = periodictable.D
tritium: Isotope = periodictable.T
neutron: Element = periodictable.n

# Test isotopes have isotope attribute
D_iso: int = periodictable.D.isotope
Dion_iso: int = periodictable.D.ion[1].isotope
Fe56_iso: int = periodictable.Fe[56].isotope

# Test that elements do not
assert not hasattr(periodictable.H, "isotope")
assert not hasattr(periodictable.H.ion[1], "isotope")