-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added gh-actions for test automation (#4)
- Loading branch information
Showing
10 changed files
with
147 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Tests | ||
|
||
on: | ||
- push | ||
- pull_request | ||
|
||
jobs: | ||
test: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest] | ||
python-version: ['3.10'] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install tox tox-gh-actions | ||
- name: Test with tox | ||
run: tox |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,7 @@ TPOT2.egg-info | |
*.json | ||
joblib/ | ||
cache_folder/ | ||
dask-worker-space/ | ||
dask-worker-space/ | ||
.tox/ | ||
*.egg-info/ | ||
.coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
[build-system] | ||
requires = ["setuptools", "wheel"] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[tool.pytest.ini_options] | ||
addopts = "--cov=tpot2" | ||
testpaths = [ | ||
"tpot2/tests", | ||
] | ||
|
||
[tool.mypy] | ||
mypy_path = "tpot2" | ||
check_untyped_defs = true | ||
disallow_any_generics = true | ||
ignore_missing_imports = true | ||
no_implicit_optional = true | ||
show_error_codes = true | ||
strict_equality = true | ||
warn_redundant_casts = true | ||
warn_return_any = true | ||
warn_unreachable = true | ||
warn_unused_configs = true | ||
no_implicit_reexport = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
flake8==6.0.0 | ||
tox==4.4.12 | ||
pytest==7.3.0 | ||
pytest-cov==4.0.0 | ||
mypy==1.2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[options.extras_require] | ||
testing = | ||
pytest>=6.0 | ||
pytest-cov>=2.0 | ||
mypy>=0.910 | ||
flake8>=3.9 | ||
tox>=3.24 | ||
|
||
[options.package_data] | ||
tpot2 = py.typed | ||
|
||
[flake8] | ||
max-line-length = 120 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
[tox] | ||
minversion = 3.28.0 | ||
# flake8 and mypy outputs severla errors, so we disable them for now | ||
# envlist = py310, flake8, mypy | ||
envlist = py310 | ||
isolated_build = true | ||
|
||
[gh-actions] | ||
python = | ||
3.10: py310 | ||
# 3.10: py310, flake8, mypy | ||
|
||
[testenv] | ||
setenv = | ||
PYTHONPATH = {toxinidir} | ||
deps = | ||
-r{toxinidir}/requirements_dev.txt | ||
commands = | ||
pytest --basetemp={envtmpdir} | ||
|
||
[testenv:flake8] | ||
basepython = python3.10 | ||
deps = flake8 | ||
commands = flake8 tpot2 | ||
|
||
[testenv:mypy] | ||
basepython = python3.10 | ||
deps = | ||
-r{toxinidir}/requirements_dev.txt | ||
commands = mypy tpot2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import pytest | ||
import sys | ||
|
||
|
||
@pytest.fixture | ||
def capture_stdout(monkeypatch): | ||
buffer = {"stdout": "", "write_calls": 0} | ||
|
||
def fake_write(s): | ||
buffer["stdout"] += s | ||
buffer["write_calls"] += 1 | ||
|
||
monkeypatch.setattr(sys.stdout, "write", fake_write) | ||
return buffer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
""" | ||
Test hello world. | ||
Notes: | ||
parameterizing the test_input and expected values allows tests continue running even if one fails. | ||
xfail marks a test as expected to fail. This is useful for tests that are not yet implemented. | ||
fixtures are used to setup and teardown tests. They are useful for tests that require a lot of setup. | ||
We can implement fixtures if we need them. | ||
""" | ||
|
||
import pytest | ||
|
||
|
||
@pytest.mark.parametrize("test_input,expected", [ | ||
("Hello World", "Hello World"), | ||
]) | ||
def test_hello_world(test_input, expected): | ||
assert test_input is expected | ||
|
||
|
||
@pytest.mark.xfail(reason="Not yet implemented") | ||
def test_divide_by_zero(): | ||
assert 1 / 0 == 1 | ||
|
||
|
||
def test_print(capture_stdout): | ||
print("Hello World") | ||
assert capture_stdout["stdout"] == "Hello World\n" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters