Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/.tests-python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Unit tests

on:
push:
pull_request:

jobs:
tests:
name: python ${{ matrix.python-version }}
runs-on: ubuntu-latest
container: python:${{ matrix.python-version }}
strategy:
matrix:
python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13" ]
steps:
- uses: actions/checkout@v3
- name: Upgrade pip
run: python3 -m pip install --upgrade pip
- name: Create and source virtual environment
run: |
python3 -m venv .venv
. .venv/bin/activate
- name: Install requirements
run: python3 -m pip install -r requirements.txt
- name: Run unit tests
run: python -m unittest
10 changes: 5 additions & 5 deletions staticmap/tests.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
from unittest import TestCase

from staticmap import StaticMap
from staticmap.staticmap import _lat_to_y, _lon_to_x, _y_to_lat, _x_to_lon


class LonLatConversionTest(TestCase):
def testLon(self):
for lon in range(-180, 180, 20):
for zoom in range(0, 10):
x = _lon_to_x(zoom)
l = _x_to_lon(zoom)
x = _lon_to_x(lon, zoom)
l = _x_to_lon(x, zoom)
self.assertAlmostEqual(lon, l, places=5)

def testLat(self):
for lat in range(-89, 89, 2):
for zoom in range(0, 10):
y = _lat_to_y(zoom)
l = _y_to_lat(zoom)
y = _lat_to_y(lat, zoom)
l = _y_to_lat(y, zoom)
self.assertAlmostEqual(lat, l, places=5)