Skip to content

Commit

Permalink
Start tests
Browse files Browse the repository at this point in the history
  • Loading branch information
orome committed Oct 23, 2023
1 parent d5d81db commit 1e9c3d3
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 23 deletions.
55 changes: 39 additions & 16 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,60 @@ jobs:

test:

name: ${{ matrix.python-version }}
runs-on: ubuntu-latest
name: Python ${{ matrix.python-version }} (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [3.9]
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.10", "3.11", "3.12"]
exclude:
- os: macos-latest
python-version: "3.9"
- os: windows-latest
python-version: "3.9"

steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Check out repo
uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
- name: Set up Python (${{ matrix.python-version }})
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Display Python version
run: python -c "import sys; print(sys.version)"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install -r requirements.txt
- name: Run eyeball tests
run: python tests/eyeball.py

- name: Test with pytest
run: |
pip install pytest
pytest tests/ --maxfail=3 --showlocals --color=yes -v
# if [ -f requirements.txt ]; then pip install -r requirements.txt; fi

# pip install pytest pytest-cov
# pytest tests.py --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html

#- name: Lint with Ruff
# run: |
# pip install ruff
# ruff --output-format=github .
# continue-on-error: true

# - name: Lint with flake8
# run: |
# # stop the build if there are Python syntax errors or undefined names
# flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
# flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics

- name: Run eyeball tests
run: python tests/eyeball.py

- name: Test with pytest
run: pytest tests/ --maxfail=2 --showlocals
4 changes: 4 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env python
# encoding: utf8

# Required for imports in scripts in tests/ to work
5 changes: 5 additions & 0 deletions tests/eyeball.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@
import sys
import os
sys.path.append(os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..')))
from automata import *

eg_ca = CellularAutomata(30, '1000000', frame_steps=10, frame_width=31)

print(eg_ca)
6 changes: 6 additions & 0 deletions tests/test_report.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from automata import __version__


def test_package_version() -> None:
print(f"\nversion: {__version__}")
assert True
12 changes: 5 additions & 7 deletions tests/test_stub.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#!/usr/bin/env python
# encoding: utf8
# sys.path.append(os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..')))
from automata import *

import sys
import os
sys.path.append(os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..')))

def test_placeholder() -> None:
pass
def test_automaton() -> None:
test_ca = CellularAutomata(30, '1000000', frame_steps=10, frame_width=31)
assert ''.join(test_ca._lattice[4]) == '0000000011001000100000000000000'

0 comments on commit 1e9c3d3

Please sign in to comment.