How to Run Tests for mvanhorn/last30days-skill: A Complete pytest Guide

Run the full test suite with python -m pytest -v tests/ from the repository root, or isolate tests from your local configuration by setting LAST30DAYS_CONFIG_DIR="" to prevent accidental API calls.

The mvanhorn/last30days-skill repository includes a comprehensive pytest-based test suite located in the tests/ directory. This suite validates the core research engine, environment-configuration helpers, and individual source adapters for platforms like Reddit, X, and YouTube. Understanding how to execute these tests ensures you can verify code changes without introducing regressions in the skill's data-gathering pipeline.

Prerequisites and Test Structure

Before running tests, ensure you have Python installed with the repository's dependencies available. The test suite comprises approximately 320 tests covering multiple components:

  • Configuration management (scripts/lib/env.py)
  • Entity extraction pipelines
  • Source adapters (Reddit, TikTok, X/Twitter, YouTube)
  • Integration logic in the main entry point

All runtime dependencies required by the tests are declared in the repository; no additional test-specific packages are necessary.

Running the Full Test Suite

To execute the complete test suite from the repository root, use the standard pytest module invocation:

python -m pytest -v tests/

The -v flag enables verbose mode, showing individual test names and their pass/fail status. This command discovers and runs all Python files matching test_*.py or *_test.py within the tests/ directory and its subdirectories.

Configuring the Test Environment

The skill loads configuration from multiple locations: a global ~/.config/last30days/.env file, a per-project .claude/last30days.env file, and environment variables. Some tests require a clean environment to avoid using real API keys or making accidental network requests.

Force "no config" mode by unsetting the configuration directory:

LAST30DAYS_CONFIG_DIR="" python -m pytest -v tests/

This works because env.py checks the LAST30DAYS_CONFIG_DIR variable at import time. An empty string signals the configuration loader to skip file-based configs, ensuring tests rely solely on in-process mocks.

Running Specific Tests

When developing or debugging, running the entire suite is inefficient. Pytest offers several methods to target specific test subsets.

By File or Directory

Execute only the tests for a specific source adapter:

python -m pytest -v tests/test_reddit_sc.py tests/test_tiktok.py

Or run configuration-specific tests:

python -m pytest -v tests/test_env_project.py

By Test Markers

The test suite uses markers to categorize tests. Common markers include slow and network.

Run only fast, pure-logic tests while excluding slow or network-dependent ones:

python -m pytest -v -m "not slow"

By Individual Test Case

Target a specific test class or method using Python's path notation:

python -m pytest -v tests/test_env_project.py::TestConfigPrecedence::test_env_var_overrides_project

This pattern follows file.py::TestClass::test_method, allowing surgical precision when iterating on fixes.

Understanding Key Test Files

Several files define the behavioral contract of the skill and warrant specific attention when running tests:

  • tests/test_env_project.py – Validates project-specific .env discovery, configuration-source precedence, and permission-warning handling in the environment loader.
  • scripts/lib/env.py – The central configuration loader that determines whether to use env-vars, global .env, or project .env files; tested for lookup and precedence logic.
  • tests/test_entity_extract.py – Exercises the entity-extraction pipeline that transforms raw source data into structured entities.
  • tests/test_reddit_sc.py and tests/test_tiktok.py – Source-specific adapters ensuring API-key handling and graceful fallback behavior for ScrapeCreators Reddit and TikTok integrations.
  • tests/test_x_source.py – Verifies X/Twitter source selection logic, including Bird client detection and XAI fallback mechanisms.
  • scripts/last30days.py – The main entry point indirectly exercised by integration tests to ensure end-to-end functionality.

Programmatic Test Execution

For custom CI pipelines or automated verification scripts, invoke pytest programmatically using Python's subprocess module:

import subprocess
import os

# Ensure a clean config environment

env = os.environ.copy()
env["LAST30DAYS_CONFIG_DIR"] = ""

# Run pytest with verbose output

result = subprocess.run(
    ["python", "-m", "pytest", "-v", "tests/"],
    env=env,
    capture_output=True,
    text=True,
)

print("=== pytest stdout ===")
print(result.stdout)
print("=== pytest stderr ===")
print(result.stderr)
print("Return code:", result.returncode)

This approach mirrors the manual clean-config workflow while capturing output for logging or further processing.

Summary

  • Run the full suite with python -m pytest -v tests/ from the repository root.
  • Isolate tests from local config by setting LAST30DAYS_CONFIG_DIR="" to prevent accidental API calls.
  • Target specific tests using file paths, markers like -m "not slow", or node IDs like file.py::Class::method.
  • Key files include tests/test_env_project.py for configuration logic and tests/test_reddit_sc.py for source adapters.
  • CI alignment – The repository's GitHub Actions runs the same pytest command, ensuring local results match the automated pipeline.

Frequently Asked Questions

How do I prevent tests from using my real API keys?

Set the LAST30DAYS_CONFIG_DIR environment variable to an empty string before running pytest. This forces the env.py loader to skip global and project-specific .env files, ensuring tests use mocked credentials.

Can I run tests without installing extra dependencies?

Yes. According to the mvanhorn/last30days-skill source code, all dependencies required for testing are included in the repository's standard requirements. No separate test packages are needed beyond the runtime dependencies.

Why are some tests marked as "slow"?

Tests marked with the slow marker typically involve complex data processing, heavy parsing operations, or external service simulation that takes longer than instantaneous unit tests. Exclude them with python -m pytest -m "not slow" for rapid feedback during development.

How do I test only the Reddit or TikTok source adapters?

Run pytest with the specific test file path: python -m pytest tests/test_reddit_sc.py for Reddit or python -m pytest tests/test_tiktok.py for TikTok. This executes only the adapter-specific logic without running the full 320-test suite.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →