diff --git a/.github/workflows/build_docs.yaml b/.github/workflows/build_docs.yaml index d310439..a302d5d 100644 --- a/.github/workflows/build_docs.yaml +++ b/.github/workflows/build_docs.yaml @@ -16,7 +16,7 @@ jobs: with: python-version: '3.11' - name: Install dependencies and local packages - run: python -m pip install sphinx pydata-sphinx-theme sphinx-autoapi sphinx-design + run: python -m pip install sphinx pydata-sphinx-theme "sphinx-autoapi != 3.4.0" sphinx-design - name: Build HTML documentation with Sphinx run: | make html diff --git a/.github/workflows/check_docs.yaml b/.github/workflows/check_docs.yaml index 50631e5..b454d58 100644 --- a/.github/workflows/check_docs.yaml +++ b/.github/workflows/check_docs.yaml @@ -14,7 +14,7 @@ jobs: with: python-version: '3.11' - name: Install dependencies and local packages - run: python -m pip install sphinx pydata-sphinx-theme sphinx-autoapi sphinx-design + run: python -m pip install sphinx pydata-sphinx-theme "sphinx-autoapi != 3.4.0" sphinx-design - name: Build HTML documentation with Sphinx run: | make html diff --git a/src/tempe/data_view.py b/src/tempe/data_view.py index 4cd285f..8eaef2a 100644 --- a/src/tempe/data_view.py +++ b/src/tempe/data_view.py @@ -270,7 +270,7 @@ def __iter__(self): i = self.start while True: yield i - i += 1 + i += self.step def __len__(self): return None diff --git a/tests/tempe/test_data_views.py b/tests/tempe/test_data_views.py new file mode 100644 index 0000000..5470461 --- /dev/null +++ b/tests/tempe/test_data_views.py @@ -0,0 +1,56 @@ +# SPDX-FileCopyrightText: 2024-present Unital Software <info@unital.dev> +# +# SPDX-License-Identifier: MIT + +import unittest + +from tempe.data_view import Count + + +class TestCount(unittest.TestCase): + + def test_count(self): + """Test count starts and steps as expected.""" + + count = Count(10, 5) + count_iter = iter(count) + + self.assertEqual(next(count_iter), 10) + self.assertEqual(next(count_iter), 15) + self.assertEqual(next(count_iter), 20) + + def test_count_getitem(self): + """Test count getitem works as expected.""" + + count = Count(10, 5) + + self.assertEqual(count[0], 10) + self.assertEqual(count[1], 15) + self.assertEqual(count[2], 20) + + def test_count_default(self): + """Test count default starts and steps as expected.""" + + count = Count() + count_iter = iter(count) + + self.assertEqual(next(count_iter), 0) + self.assertEqual(next(count_iter), 1) + self.assertEqual(next(count_iter), 2) + + def test_count_default_getitem(self): + """Test count default getitem works as expected.""" + + count = Count() + + self.assertEqual(count[0], 0) + self.assertEqual(count[1], 1) + self.assertEqual(count[2], 2) + + +if __name__ == "__main__": + result = unittest.main() + if not result.wasSuccessful(): + import sys + + sys.exit(1)