Skip to content

Commit

Permalink
Move tests into top-level of project (#2833)
Browse files Browse the repository at this point in the history
* Move tests into root of package

* Remove tests from package in setup.py

* Make all test imports absolute

* Move rc-specific helper into relevant module

* Update make test invocation

* Mention in release notes [skip actions]
  • Loading branch information
mwaskom committed Jun 4, 2022
1 parent e2cae52 commit 627c6c2
Show file tree
Hide file tree
Showing 39 changed files with 79 additions and 80 deletions.
4 changes: 2 additions & 2 deletions Makefile
@@ -1,10 +1,10 @@
export SHELL := /bin/bash

test:
pytest -n auto --doctest-modules --cov=seaborn --cov-config=.coveragerc seaborn
pytest -n auto --doctest-modules --cov=seaborn --cov=tests --cov-config=.coveragerc seaborn tests

unittests:
pytest -n auto --cov=seaborn --cov-config=.coveragerc seaborn
pytest -n auto --cov=seaborn --cov=tests --cov-config=.coveragerc tests

lint:
flake8 seaborn
Expand Down
3 changes: 2 additions & 1 deletion doc/releases/v0.12.0.txt
Expand Up @@ -63,9 +63,10 @@ Other updates

- |Fix| In :func:`lineplot`, allowed the `dashes` keyword to set the style of a line without mapping a `style` variable (:pr:`2449`).


- |Dependencies| Made `scipy` an optional dependency and added `pip install seaborn[all]` as a method for ensuring the availability of compatible `scipy` and `statsmodels` libraries at install time. This has a few minor implications for existing code, which are explained in the Github pull request (:pr:`2398`).

- |Dependencies| Following `NEP29 <https://numpy.org/neps/nep-0029-deprecation_policy.html>`_, dropped support for Python 3.6 and bumped the minimally-supported versions of the library dependencies.

- |Dependencies| The unit test suite is no longer part of the source or wheel distribution. Seaborn has never had a runtime API for exercising the tests, so this should not have workflow implications (:pr:`2833`).

- |API| Removed several previously-deprecated utility functions (`iqr`, `percentiles`, `pmf_hist`, and `sort_df`).
1 change: 0 additions & 1 deletion setup.py
Expand Up @@ -51,7 +51,6 @@
'seaborn._stats',
'seaborn.colors',
'seaborn.external',
'seaborn.tests',
'seaborn._core',
'seaborn._marks',
'seaborn._stats',
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
23 changes: 0 additions & 23 deletions seaborn/conftest.py → tests/conftest.py
Expand Up @@ -7,29 +7,6 @@
import pytest


def has_verdana():
"""Helper to verify if Verdana font is present"""
# This import is relatively lengthy, so to prevent its import for
# testing other tests in this module not requiring this knowledge,
# import font_manager here
import matplotlib.font_manager as mplfm
try:
verdana_font = mplfm.findfont('Verdana', fallback_to_default=False)
except: # noqa
# if https://github.com/matplotlib/matplotlib/pull/3435
# gets accepted
return False
# otherwise check if not matching the logic for a 'default' one
try:
unlikely_font = mplfm.findfont("very_unlikely_to_exist1234",
fallback_to_default=False)
except: # noqa
# if matched verdana but not unlikely, Verdana must exist
return True
# otherwise -- if they match, must be the same default
return verdana_font != unlikely_font


@pytest.fixture(scope="session", autouse=True)
def remove_pandas_unit_conversion():
# Prior to pandas 1.0, it registered its own datetime converters,
Expand Down
4 changes: 2 additions & 2 deletions seaborn/tests/test_algorithms.py → tests/test_algorithms.py
Expand Up @@ -4,8 +4,8 @@
import pytest
from numpy.testing import assert_array_equal

from .. import algorithms as algo
from ..external.version import Version
from seaborn import algorithms as algo
from seaborn.external.version import Version


@pytest.fixture
Expand Down
16 changes: 8 additions & 8 deletions seaborn/tests/test_axisgrid.py → tests/test_axisgrid.py
Expand Up @@ -11,14 +11,14 @@
except ImportError:
import pandas.util.testing as tm

from .._oldcore import categorical_order
from .. import rcmod
from ..palettes import color_palette
from ..relational import scatterplot
from ..distributions import histplot, kdeplot, distplot
from ..categorical import pointplot
from .. import axisgrid as ag
from .._testing import (
from seaborn._oldcore import categorical_order
from seaborn import rcmod
from seaborn.palettes import color_palette
from seaborn.relational import scatterplot
from seaborn.distributions import histplot, kdeplot, distplot
from seaborn.categorical import pointplot
from seaborn import axisgrid as ag
from seaborn._testing import (
assert_plots_equal,
assert_colors_equal,
)
Expand Down
16 changes: 8 additions & 8 deletions seaborn/tests/test_categorical.py → tests/test_categorical.py
Expand Up @@ -15,21 +15,21 @@
assert_array_less,
)

from .. import categorical as cat
from .. import palettes
from seaborn import categorical as cat
from seaborn import palettes

from ..external.version import Version
from .._oldcore import categorical_order
from ..categorical import (
from seaborn.external.version import Version
from seaborn._oldcore import categorical_order
from seaborn.categorical import (
_CategoricalPlotterNew,
Beeswarm,
catplot,
stripplot,
swarmplot,
)
from ..palettes import color_palette
from ..utils import _normal_quantile_func, _draw_figure
from .._testing import assert_plots_equal
from seaborn.palettes import color_palette
from seaborn.utils import _normal_quantile_func, _draw_figure
from seaborn._testing import assert_plots_equal


PLOT_FUNCS = [
Expand Down
6 changes: 3 additions & 3 deletions seaborn/tests/test_core.py → tests/test_core.py
Expand Up @@ -8,8 +8,8 @@
from numpy.testing import assert_array_equal
from pandas.testing import assert_frame_equal

from ..axisgrid import FacetGrid
from .._oldcore import (
from seaborn.axisgrid import FacetGrid
from seaborn._oldcore import (
SemanticMapping,
HueMapping,
SizeMapping,
Expand All @@ -22,7 +22,7 @@
categorical_order,
)

from ..palettes import color_palette
from seaborn.palettes import color_palette


try:
Expand Down
@@ -1,5 +1,5 @@
import inspect
from .._decorators import share_init_params_with_map
from seaborn._decorators import share_init_params_with_map


def test_share_init_params_with_map():
Expand Down
Expand Up @@ -8,20 +8,20 @@
import pytest
from numpy.testing import assert_array_equal, assert_array_almost_equal

from .. import distributions as dist
from ..palettes import (
from seaborn import distributions as dist
from seaborn.palettes import (
color_palette,
light_palette,
)
from .._oldcore import (
from seaborn._oldcore import (
categorical_order,
)
from .._statistics import (
from seaborn._statistics import (
KDE,
Histogram,
_no_scipy,
)
from ..distributions import (
from seaborn.distributions import (
_DistributionPlotter,
displot,
distplot,
Expand All @@ -30,9 +30,9 @@
kdeplot,
rugplot,
)
from ..external.version import Version
from ..axisgrid import FacetGrid
from .._testing import (
from seaborn.external.version import Version
from seaborn.axisgrid import FacetGrid
from seaborn._testing import (
assert_plots_equal,
assert_legends_equal,
assert_colors_equal,
Expand Down
@@ -1,4 +1,4 @@
from .._docstrings import DocstringComponents
from seaborn._docstrings import DocstringComponents


EXAMPLE_DICT = dict(
Expand Down
6 changes: 3 additions & 3 deletions seaborn/tests/test_matrix.py → tests/test_matrix.py
Expand Up @@ -27,9 +27,9 @@
import pandas.util.testing as pdt
import pytest

from .. import matrix as mat
from .. import color_palette
from .._testing import assert_colors_equal
from seaborn import matrix as mat
from seaborn import color_palette
from seaborn._testing import assert_colors_equal


class TestHeatmap:
Expand Down
4 changes: 2 additions & 2 deletions seaborn/tests/test_miscplot.py → tests/test_miscplot.py
@@ -1,7 +1,7 @@
import matplotlib.pyplot as plt

from .. import miscplot as misc
from ..palettes import color_palette
from seaborn import miscplot as misc
from seaborn.palettes import color_palette
from .test_utils import _network


Expand Down
6 changes: 3 additions & 3 deletions seaborn/tests/test_palettes.py → tests/test_palettes.py
Expand Up @@ -5,9 +5,9 @@
import pytest
import numpy.testing as npt

from .. import palettes, utils, rcmod
from ..external import husl
from ..colors import xkcd_rgb, crayons
from seaborn import palettes, utils, rcmod
from seaborn.external import husl
from seaborn.colors import xkcd_rgb, crayons


class TestColorPalettes:
Expand Down
26 changes: 24 additions & 2 deletions seaborn/tests/test_rcmod.py → tests/test_rcmod.py
Expand Up @@ -4,8 +4,30 @@
import matplotlib.pyplot as plt
import numpy.testing as npt

from .. import rcmod, palettes, utils
from ..conftest import has_verdana
from seaborn import rcmod, palettes, utils


def has_verdana():
"""Helper to verify if Verdana font is present"""
# This import is relatively lengthy, so to prevent its import for
# testing other tests in this module not requiring this knowledge,
# import font_manager here
import matplotlib.font_manager as mplfm
try:
verdana_font = mplfm.findfont('Verdana', fallback_to_default=False)
except: # noqa
# if https://github.com/matplotlib/matplotlib/pull/3435
# gets accepted
return False
# otherwise check if not matching the logic for a 'default' one
try:
unlikely_font = mplfm.findfont("very_unlikely_to_exist1234",
fallback_to_default=False)
except: # noqa
# if matched verdana but not unlikely, Verdana must exist
return True
# otherwise -- if they match, must be the same default
return verdana_font != unlikely_font


class RCParamTester:
Expand Down
6 changes: 3 additions & 3 deletions seaborn/tests/test_regression.py → tests/test_regression.py
Expand Up @@ -16,9 +16,9 @@
except ImportError:
_no_statsmodels = True

from .. import regression as lm
from ..external.version import Version
from ..palettes import color_palette
from seaborn import regression as lm
from seaborn.external.version import Version
from seaborn.palettes import color_palette

rs = np.random.RandomState(0)

Expand Down
10 changes: 5 additions & 5 deletions seaborn/tests/test_relational.py → tests/test_relational.py
Expand Up @@ -7,10 +7,10 @@
import pytest
from numpy.testing import assert_array_equal

from ..external.version import Version
from ..palettes import color_palette
from seaborn.external.version import Version
from seaborn.palettes import color_palette

from ..relational import (
from seaborn.relational import (
_RelationalPlotter,
_LinePlotter,
_ScatterPlotter,
Expand All @@ -19,8 +19,8 @@
scatterplot
)

from ..utils import _draw_figure
from .._testing import assert_plots_equal
from seaborn.utils import _draw_figure
from seaborn._testing import assert_plots_equal


@pytest.fixture(params=[
Expand Down
Expand Up @@ -9,7 +9,7 @@
import pytest
from numpy.testing import assert_array_equal, assert_array_almost_equal

from .._statistics import (
from seaborn._statistics import (
KDE,
Histogram,
ECDF,
Expand Down
6 changes: 3 additions & 3 deletions seaborn/tests/test_utils.py → tests/test_utils.py
Expand Up @@ -18,9 +18,9 @@
assert_frame_equal,
)

from .. import utils, rcmod
from ..external.version import Version
from ..utils import (
from seaborn import utils, rcmod
from seaborn.external.version import Version
from seaborn.utils import (
get_dataset_names,
get_color_cycle,
remove_na,
Expand Down

0 comments on commit 627c6c2

Please sign in to comment.