Add pytest unit tests
This commit is contained in:
parent
8fc5206e95
commit
306d6fd13f
4 changed files with 49 additions and 2 deletions
9
.vscode/settings.json
vendored
9
.vscode/settings.json
vendored
|
@ -1,4 +1,9 @@
|
||||||
{
|
{
|
||||||
"python.linting.pylintEnabled": true,
|
"python.linting.pylintEnabled": true,
|
||||||
"python.linting.enabled": true
|
"python.linting.enabled": true,
|
||||||
}
|
"python.testing.pytestArgs": [
|
||||||
|
"test"
|
||||||
|
],
|
||||||
|
"python.testing.unittestEnabled": false,
|
||||||
|
"python.testing.pytestEnabled": true
|
||||||
|
}
|
||||||
|
|
|
@ -1,15 +1,21 @@
|
||||||
astroid==2.14.1
|
astroid==2.14.1
|
||||||
|
attrs==22.2.0
|
||||||
autopep8==2.0.1
|
autopep8==2.0.1
|
||||||
cffi==1.15.0
|
cffi==1.15.0
|
||||||
dill==0.3.6
|
dill==0.3.6
|
||||||
|
exceptiongroup==1.1.0
|
||||||
|
iniconfig==2.0.0
|
||||||
isort==5.12.0
|
isort==5.12.0
|
||||||
lazy-object-proxy==1.9.0
|
lazy-object-proxy==1.9.0
|
||||||
mccabe==0.7.0
|
mccabe==0.7.0
|
||||||
numpy==1.22.3
|
numpy==1.22.3
|
||||||
|
packaging==23.0
|
||||||
platformdirs==3.0.0
|
platformdirs==3.0.0
|
||||||
|
pluggy==1.0.0
|
||||||
pycodestyle==2.10.0
|
pycodestyle==2.10.0
|
||||||
pycparser==2.21
|
pycparser==2.21
|
||||||
pylint==2.16.1
|
pylint==2.16.1
|
||||||
|
pytest==7.2.1
|
||||||
tcod==13.6.1
|
tcod==13.6.1
|
||||||
tomli==2.0.1
|
tomli==2.0.1
|
||||||
tomlkit==0.11.6
|
tomlkit==0.11.6
|
||||||
|
|
1
test/__init__.py
Normal file
1
test/__init__.py
Normal file
|
@ -0,0 +1 @@
|
||||||
|
# Eryn Wells <eryn@erynwells.me>
|
35
test/test_geometry_point.py
Normal file
35
test/test_geometry_point.py
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
# Eryn Wells <eryn@erynwells.me>
|
||||||
|
|
||||||
|
from erynrl.geometry import Point
|
||||||
|
|
||||||
|
|
||||||
|
def test_point_neighbors():
|
||||||
|
'''Check that Point.neighbors returns all neighbors'''
|
||||||
|
test_point = Point(5, 5)
|
||||||
|
|
||||||
|
expected_neighbors = set([
|
||||||
|
Point(4, 4),
|
||||||
|
Point(5, 4),
|
||||||
|
Point(6, 4),
|
||||||
|
Point(4, 5),
|
||||||
|
# Point(5, 5),
|
||||||
|
Point(6, 5),
|
||||||
|
Point(4, 6),
|
||||||
|
Point(5, 6),
|
||||||
|
Point(6, 6),
|
||||||
|
])
|
||||||
|
|
||||||
|
neighbors = set(test_point.neighbors)
|
||||||
|
for pt in expected_neighbors:
|
||||||
|
assert pt in neighbors
|
||||||
|
|
||||||
|
assert expected_neighbors - neighbors == set(), \
|
||||||
|
f"Found some points that didn't belong in the set of neighbors of {test_point}"
|
||||||
|
|
||||||
|
|
||||||
|
def test_point_manhattan_distance():
|
||||||
|
'''Check that the Manhattan Distance calculation on Points is correct'''
|
||||||
|
point_a = Point(3, 2)
|
||||||
|
point_b = Point(8, 5)
|
||||||
|
|
||||||
|
assert point_a.manhattan_distance_to(point_b) == 8
|
Loading…
Add table
Add a link
Reference in a new issue