Skip to content

Commit

Permalink
add tests to highlight ordinal differences
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexisBRENON committed Jul 22, 2024
1 parent f55705f commit ec7ffac
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Install
run: pip install '.[testing]' 'urllib3<1.27'
- name: Test with pytest
run: pytest
run: pytest --cov ewmh_m2m --cov-report term-missing

publish:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ docs/_rst/*
docs/_build/*
cover/*
MANIFEST
_version.py

# Per-project virtualenvs
.venv*/
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ move-to-monitor = "ewmh_m2m.__main__:main"


[tool.pytest.ini_options]
addopts = "--cov ewmh_m2m --cov-report term-missing --verbose"
addopts = "--verbose"
norecursedirs = [
"dist",
"build",
Expand Down
29 changes: 14 additions & 15 deletions src/ewmh_m2m/__init__.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
# file generated by setuptools_scm
# don't change, don't track in version control
TYPE_CHECKING = False
if TYPE_CHECKING:
from typing import Tuple, Union
VERSION_TUPLE = Tuple[Union[int, str], ...]
else:
VERSION_TUPLE = object
from ._version import (
version,
__version__,
version_tuple,
__version_tuple__,
VERSION_TUPLE,
)

version: str
__version__: str
__version_tuple__: VERSION_TUPLE
version_tuple: VERSION_TUPLE

__version__ = version = '2.0.1.dev3+g99db25e.d20240514'
__version_tuple__ = version_tuple = (2, 0, 1, 'dev3', 'g99db25e.d20240514')
__all__ = [
"version",
"__version__",
"version_tuple",
"__version_tuple__",
"VERSION_TUPLE",
]
30 changes: 30 additions & 0 deletions tests/test_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,43 @@ def test_overlap(self):
assert g2.overlap(g1)

def test_directions_aligned(self):
"""
0 1 2
0 +----+----+
| g1 | g2 |
1 +----+----+
"""
g1 = Geometry(0, 0, 1, 1)
g2 = Geometry(1, 0, 1, 1)

assert g1.directions_to(g2) == {Ordinal.EAST, Ordinal.EAST_NORTHEAST, Ordinal.EAST_SOUTHEAST}

def test_directions_not_aligned(self):
"""
0 1 2
0 +----+
| g1 |
1 +----+----+
| g2 |
2 +----+
"""
g1 = Geometry(0, 0, 1, 1)
g2 = Geometry(1, 1, 1, 1)

assert g1.directions_to(g2) == {Ordinal.SOUTH_SOUTHEAST, Ordinal.SOUTHEAST, Ordinal.EAST_SOUTHEAST}

def test_directions_overlap(self):
"""
0 2 4
0 +----+
1 | g1 +----+
2 +----+ g2 |
3 +----+
"""
g1 = Geometry(0, 0, 2, 2)
g2 = Geometry(2, 1, 2, 2)

assert g1.directions_to(g2) == {
Ordinal.EAST,
Ordinal.EAST_SOUTHEAST,
}

0 comments on commit ec7ffac

Please sign in to comment.