Skip to content

Commit

Permalink
Add a pytest setup
Browse files Browse the repository at this point in the history
- setup pytest test folder and configs with just a dummy test for now
  • Loading branch information
honzaflash committed Feb 27, 2025
1 parent 211afa7 commit 5a88923
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
30 changes: 30 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Pytest configuration."""

import pytest


def pytest_addoption(parser):
"""Adds --integration option to pytest."""
parser.addoption(
"--integration",
action="store_true",
default=False,
help="Run integration tests.",
)


def pytest_configure(config):
"""Adds marker for slow."""
config.addinivalue_line("markers", "integration: mark test as an integration test")


def pytest_collection_modifyitems(config, items):
"""Skips tests marked slow if --integration isn't used."""
if config.getoption("--integration"):
return
skip_integration = pytest.mark.skip(reason="need --integration option to run")
for item in items:
if "integration" in item.keywords:
item.add_marker(skip_integration)
1 change: 1 addition & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Unit test package for fact-species-viz."""
15 changes: 15 additions & 0 deletions tests/test_fact_species_viz.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env python

"""Tests for `fact_species_viz` package."""

import pytest


@pytest.fixture
def example_data() -> str:
return "hi"


def test_content(example_data):
"""Sample pytest test function with the pytest fixture as an argument."""
assert example_data == "hi"

0 comments on commit 5a88923

Please sign in to comment.