Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nox test session on windows, add it to github actions #21

Merged
merged 1 commit into from
Aug 13, 2020
Merged
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
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ jobs:
- { python-version: 3.8, os: ubuntu-latest }
- { python-version: 3.7, os: ubuntu-latest }
- { python-version: 3.6, os: ubuntu-latest }
# - { python-version: 3.8, os: windows-latest }
- { python-version: 3.8, os: windows-latest }
- { python-version: 3.8, os: macos-latest }

steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
python-version: ${{ matrix.python-version }}
# architecture: x64
architecture: x64
- run: pip install nox==2020.5.24
- run: pip install poetry==1.0.9
- run: nox
18 changes: 10 additions & 8 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Nox Sessions."""
import tempfile
from pathlib import Path

import nox

Expand All @@ -9,23 +10,24 @@

def install_with_constraints(session, *args, **kwargs):
"""Install packages constrained by Poetry's lock file."""
with tempfile.NamedTemporaryFile() as requirements:
with tempfile.TemporaryDirectory() as directory:
requirements = Path(directory) / "requirements.txt"
session.run(
"poetry",
"export",
"--dev",
"--format=requirements.txt",
f"--output={requirements.name}",
f"--output={requirements}",
external=True,
)
session.install(f"--constraint={requirements.name}", *args, **kwargs)
session.install(f"--constraint={requirements}", *args, **kwargs)


@nox.session()
def tests(session):
"""Run the test suite."""
args = session.posargs or ["--cov", "-m", "not e2e"]
session.run("poetry", "install", "--no-dev", external=True)
session.run("poetry", "install", external=True)
install_with_constraints(session, "coverage[toml]", "pytest", "pytest-cov")
session.run("pytest", *args)

Expand Down Expand Up @@ -64,18 +66,18 @@ def black(session):
@nox.session()
def safety(session):
"""Scan dependencies for insecure packages."""
with tempfile.NamedTemporaryFile() as requirements:
with tempfile.TemporaryDirectory() as directory:
requirements = Path(directory) / "requirements.txt"
session.run(
"poetry",
"export",
"--dev",
"--format=requirements.txt",
"--without-hashes",
f"--output={requirements.name}",
f"--output={requirements}",
external=True,
)
install_with_constraints(session, "safety")
session.run("safety", "check", f"--file={requirements.name}", "--full-report")
session.run("safety", "check", f"--file={requirements}", "--full-report")


@nox.session()
Expand Down
4 changes: 4 additions & 0 deletions tests/test_core.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import pytest

import matplotlib
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.axes import Axes
from matplotlib.figure import Figure

import seaborn_image as isns

matplotlib.use("AGG") # use non-interactive backend for tests


data = np.random.random(2500).reshape((50, 50))


Expand Down
8 changes: 5 additions & 3 deletions tests/test_filters.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest

import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import scipy.ndimage as ndi
Expand All @@ -8,6 +9,9 @@

import seaborn_image as isns

matplotlib.use("AGG") # use non-interactive backend for tests


data = np.random.random(2500).reshape((50, 50))
filter_list = ["sobel", "gaussian", "median", "max", "diff_of_gaussians"]

Expand All @@ -17,9 +21,7 @@ def test_filter_not_implemented():
isns.filterplot(data, filter="not-implemented-filter")


@pytest.mark.parametrize(
"filter", [["gaussian"], ndi.gaussian_filter, None]
)
@pytest.mark.parametrize("filter", [["gaussian"], ndi.gaussian_filter, None])
def test_filter_types(filter):
with pytest.raises(TypeError):
isns.filterplot(data, filter=filter)
Expand Down
14 changes: 13 additions & 1 deletion tests/test_general.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import pytest

import matplotlib
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.axes import Axes
from matplotlib.figure import Figure

import seaborn_image as isns

matplotlib.use("AGG") # use non-interactive backend for tests


data = np.random.random(2500).reshape((50, 50))


Expand Down Expand Up @@ -120,7 +124,15 @@ def test_imghist_return():
@pytest.mark.parametrize("title_fontdict", [{"fontsize": 20}, None])
@pytest.mark.parametrize("describe", [True, False])
def test_imghist_w_all_valid_inputs(
cmap, bins, cbar, cbar_label, cbar_fontdict, showticks, title, title_fontdict, describe
cmap,
bins,
cbar,
cbar_label,
cbar_fontdict,
showticks,
title,
title_fontdict,
describe,
):
f, axes, cax = isns.imghist(
data,
Expand Down