FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-metar/test/test_direction.py at main · python-metar/python-metar · GitHub
python-metar
/
python-metar
Public
Notifications
You must be signed in to change notification settings
Fork
125
Star
306
Code
Issues
33
Pull requests
2
Discussions
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
python-metar
/
test
/
test_direction.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
49 lines (42 loc) · 1.62 KB
Breadcrumbs
python-metar
/
test
/
test_direction.py
Copy path
File metadata and controls
49 lines (42 loc) · 1.62 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
"""Test direction."""
import
pytest
from
metar
.
Datatypes
import
direction
def
test_usage
():
"""Test basic usage."""
assert
direction
(
"90"
).
value
()
==
90.0
assert
direction
(
90
).
value
()
==
90.0
assert
direction
(
90.0
).
value
()
==
90.0
assert
direction
(
"90"
).
string
()
==
"90 degrees"
assert
direction
(
"E"
).
compass
()
==
"E"
def
test_error_checking
():
"""Test that exceptions are raised."""
with
pytest
.
raises
(
ValueError
):
direction
(
"North"
)
with
pytest
.
raises
(
ValueError
):
direction
(
-
10
)
with
pytest
.
raises
(
ValueError
):
direction
(
"361"
)
def
test_conversion
():
"""Test conversion of str direction to numeric and back."""
assert
direction
(
"N"
).
value
()
==
0.0
assert
direction
(
"NNE"
).
value
()
==
22.5
assert
direction
(
"NE"
).
value
()
==
45.0
assert
direction
(
"ENE"
).
value
()
==
67.5
assert
direction
(
"E"
).
value
()
==
90.0
assert
direction
(
"ESE"
).
value
()
==
112.5
assert
direction
(
"SE"
).
value
()
==
135.0
assert
direction
(
"SSE"
).
value
()
==
157.5
assert
direction
(
"S"
).
value
()
==
180.0
assert
direction
(
"SSW"
).
value
()
==
202.5
assert
direction
(
"SW"
).
value
()
==
225.0
assert
direction
(
"WSW"
).
value
()
==
247.5
assert
direction
(
"W"
).
value
()
==
270.0
assert
direction
(
"WNW"
).
value
()
==
292.5
assert
direction
(
"NW"
).
value
()
==
315.0
assert
direction
(
"NNW"
).
value
()
==
337.5
assert
direction
(
"0"
).
compass
()
==
"N"
assert
direction
(
"5"
).
compass
()
==
"N"
assert
direction
(
"355"
).
compass
()
==
"N"
assert
direction
(
"20"
).
compass
()
==
"NNE"
assert
direction
(
"60"
).
compass
()
==
"ENE"
assert
direction
(
"247.5"
).
compass
()
==
"WSW"
Back
|
FazBrowse Home
|
New Git URL