How to Run Graphify Tests: A Complete pytest Guide
Run Graphify tests by installing the package in editable mode with pip install -e ., installing pytest, and executing pytest from the repository root to discover all tests in the tests/ directory.
The Graphify repository (Graphify-Labs/graphify) ships with a comprehensive test suite that validates its knowledge-graph engine, language-specific resolvers, and HTTP serve layer. Learning how to run Graphify tests ensures that any modifications to the core graph logic or language parsers preserve existing functionality. This guide covers the exact commands, file locations, and pytest configurations used in the v8 codebase.
Installation and Setup
Before executing tests, you must install the package and its dependencies. Graphify uses a modern Python packaging setup defined in pyproject.toml at the repository root.
Install the package in editable mode to ensure the test suite can import internal modules directly:
pip install -e .
If the project uses Poetry, run poetry install instead to handle dependency resolution.
Next, install the test runner and optional coverage tools. While pyproject.toml may declare these as development dependencies, you can install them explicitly:
pip install pytest pytest-cov
Executing the Test Suite
From the repository root, invoke pytest to discover and run all files matching the test_*.py pattern inside the tests/ directory:
pytest
Common pytest Flags
Use these flags to control test execution and output:
-v– Enables verbose output, showing individual test names as they pass or fail.-k "<expr>"– Runs only tests matching the expression. For example,pytest -k "serve"executes only tests intests/test_serve.pyandtests/test_serve_http.py.--cov=graphify– Generates a coverage report for thegraphifypackage, highlighting untested lines in the source code.
Example command with verbose output and coverage:
pytest -v --cov=graphify
Test Structure and Coverage Areas
The tests/ directory contains targeted test modules that mirror Graphify’s architecture. Understanding these categories helps you run specific subsets when debugging.
Core Graph Operations
Tests like tests/test_zero_node_no_cache.py and tests/test_word_count_cache.py validate node creation, caching mechanisms, and basic graph queries. These ensure the underlying graph engine correctly handles edge cases and cache invalidation.
Language Resolvers
Graphify parses multiple programming languages, and the test suite verifies each resolver:
tests/test_swift_import_resolution.py– Validates Swift symbol resolution.tests/test_ts_inheritance.py– Checks TypeScript inheritance parsing.tests/test_ruby_resolution.py– Confirms Ruby-specific resolution logic.
HTTP Serve Layer
The tests/test_serve.py and tests/test_serve_http.py modules spin up temporary servers to verify request handling, routing, and response correctness. Run these with pytest -k "serve" when modifying the HTTP API in graphify/serve.py.
Skill Plugins
Dynamic skill loading is tested in tests/test_skillgen.py and tests/test_skill_version_warning.py. These ensure that plugins for VSCode, Windows, and Trae environments load correctly and handle version mismatches.
Semantic Processing
tests/test_semantic_similarity.py and tests/test_semantic_cleanup.py exercise the textual similarity utilities powering Graphify’s “semantic ID” feature, verifying that cleanup routines and similarity calculations produce consistent results.
Interpreting Test Results
pytest displays a summary of passed, failed, and skipped tests upon completion. For failures, the traceback points directly to the source line triggering the error—whether in a resolver, the serve layer, or the core graph engine. This immediate feedback loop allows rapid identification of regressions in specific components like the Swift import resolver or the HTTP server implementation.
Summary
- Install Graphify in editable mode using
pip install -e .before running tests. - Execute the full suite with
pytestfrom the repository root. - Target specific functionality using
-kflags (e.g.,-k "serve"for HTTP tests). - Generate coverage reports with
--cov=graphifyto identify untested code paths. - Key test files include
tests/test_serve.pyfor the HTTP layer andtests/test_ts_inheritance.pyfor language resolution.
Frequently Asked Questions
What test framework does Graphify use?
Graphify uses pytest as its test runner. The project defines test dependencies in pyproject.toml, and all test files follow the test_*.py naming convention within the tests/ package.
How do I run only specific tests in Graphify?
Use the -k flag with a keyword expression. For example, pytest -k "swift" runs only tests matching "swift" (such as those in tests/test_swift_import_resolution.py), while pytest -k "not serve" excludes the HTTP server tests.
Does Graphify include code coverage reporting?
Yes. Install pytest-cov and run pytest --cov=graphify to generate coverage reports. This analyzes the graphify/ package source files and reports which lines are exercised by the test suite, including tests in tests/test_zero_node_no_cache.py and other core modules.
Where are the Graphify test files located?
All test files reside in the tests/ directory at the repository root. Notable files include tests/__init__.py (the test package initializer), tests/test_semantic_similarity.py (semantic processing), and tests/test_skillgen.py (skill plugin generation).
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:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →