Skip to content

Commit

Permalink
adds pytest marks
Browse files Browse the repository at this point in the history
  • Loading branch information
Oege Dijk committed May 9, 2022
1 parent 5a120e5 commit 4142965
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 24 deletions.
11 changes: 11 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[pytest]
addopts =
--strict-markers
--strict-config
-ra

testpaths = tests

markers =
selenium: set of (costly) integration tests that start a headless chrome session to run a dashboard integration test
cli: set of tests that test the cli's (explainerdashboard and explainerhub commandline programs)
2 changes: 2 additions & 0 deletions tests/hub/test_hub_cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import pytest

pytestmark = pytest.mark.cli

def test_explainerhub_cli_help(explainer_hub_dump_folder, script_runner):
ret = script_runner.run('explainerhub', ' --help', cwd=str(explainer_hub_dump_folder))
Expand Down
21 changes: 2 additions & 19 deletions tests/hub/test_hub_integration.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import pytest

pytestmark = pytest.mark.selenium

@pytest.fixture(scope="session")
def explainer_hub_client(explainer_hub):
explainer_hub.app.config["TESTING"] = True
Expand All @@ -13,25 +15,6 @@ def explainer_hub_client(explainer_hub):
if _ctx is not None:
_ctx.pop()

# class UserTest(TestCase):
# def setUp(self):
# X_train, y_train, X_test, y_test = titanic_survive()
# model = RandomForestClassifier(n_estimators=5, max_depth=2).fit(X_train, y_train)
# explainer = ClassifierExplainer(model, X_test, y_test)
# db1 = ExplainerDashboard(explainer, description="Super interesting dashboard")
# db2 = ExplainerDashboard(explainer, title="Dashboard Two",
# logins=[['user', 'password']], name='db2')
# self.hub = ExplainerHub([db1, db2])
# self.hub.app.config["TESTING"] = True
# self.hub.app.config["WTF_CSRF_CHECK_DEFAULT"] = False
# self.client = self.hub.app.test_client()
# self._ctx = self.hub.app.test_request_context()
# self._ctx.push()

# def tearDown(self):
# if self._ctx is not None:
# self._ctx.pop()

def test_explainer_hub_client(explainer_hub_client):
with explainer_hub_client:
data = {"username": "user", "password": "password", "next": "/"}
Expand Down
8 changes: 4 additions & 4 deletions tests/integration_tests/test_customdashboards.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import dash
from sklearn.ensemble import RandomForestClassifier
import pytest

from explainerdashboard import *
from explainerdashboard.datasets import *
from explainerdashboard import ExplainerDashboard
from explainerdashboard.custom import *

pytestmark = pytest.mark.selenium

class CustomDashboard(ExplainerComponent):
def __init__(self, explainer, title="Custom Dashboard", name=None):
super().__init__(explainer)
Expand Down
3 changes: 3 additions & 0 deletions tests/integration_tests/test_dashboards.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@

import pytest

from explainerdashboard.dashboards import ExplainerDashboard

pytestmark = pytest.mark.selenium

def test_classification_dashboard(dash_duo, precalculated_rf_classifier_explainer):
db = ExplainerDashboard(precalculated_rf_classifier_explainer, title="testing", responsive=False)
Expand Down
3 changes: 2 additions & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
from explainerdashboard.datasets import titanic_survive
from explainerdashboard.custom import ShapDependenceComposite

pytestmark = pytest.mark.cli

@pytest.fixture
@pytest.fixture(scope="session")
def generate_assets():
X_train, y_train, X_test, y_test = titanic_survive()

Expand Down

0 comments on commit 4142965

Please sign in to comment.