
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
A lightweight Python test runner with method-level discovery and coverage reporting
A simple, efficient Python testing framework that provides test discovery at the method level, code coverage reporting, and basic linting capabilities. Unlike more complex testing frameworks, this lightweight solution focuses on simplicity and ease of use while still providing detailed test results.
pip pyrulesrunner
pip install pyrulesrunner
git clone <repository-url>
cd pyrulesrunner
pip install -e .
# Install with coverage support
pip install pyrulesrunner[coverage]
# Install with linting support
pip install pyrulesrunner[lint]
# Install with all optional features
pip install pyrulesrunner[all]
You can also use the standalone testrules.py
script:
# Download testrules.py to your project
# Install dependencies
pip install coverage flake8
After installation, you can use the testrules
command from anywhere:
# Run all tests
testrules
testrules --all
# Run specific test types
testrules unit
testrules integration
testrules e2e
testrules regression
# Run specific modules
testrules test_module1 test_module2
# Run test groups (defined in config)
testrules core
testrules api
# Run linting only
testrules lint
testrules --lint-only
# Run comprehensive check (linting + all tests)
testrules check
testrules --check
# Use custom configuration
testrules --config my_config.json
# Disable coverage
testrules --no-coverage
# Show help
testrules --help
You can also run it as a Python module:
python -m testrules --all
python -m testrules unit
If using the standalone script:
# Run all tests
python testrules.py
# Run specific test types
python testrules.py unit
python testrules.py integration
python testrules.py e2e
python testrules.py regression
# Run specific modules
python testrules.py test_module1 test_module2
# Run linting
python testrules.py lint
python testrules.py check
The test runner uses a testrules.json
configuration file to define test patterns, groups, and settings:
{
"test_patterns": {
"unit": ["test_*.py", "*_test.py", "unit_test_*.py"],
"integration": ["integration_test_*.py", "*_integration_test.py"],
"e2e": ["e2e_test_*.py", "*_e2e_test.py"],
"regression": ["regression_test_*.py", "*_regression_test.py"]
},
"test_groups": {
"all": [],
"core": ["test_core1", "test_core2"],
"api": ["test_api1", "test_api2"],
"fast": ["test_quick1", "test_quick2"],
"slow": ["test_slow1", "test_slow2"]
},
"coverage_enabled": true,
"html_coverage": true,
"html_coverage_dir": "htmlcov",
"coverage_config": {
"source": ["."],
"omit": [
"*/tests/*",
"*/test_*",
"*/__pycache__/*",
"*/venv/*",
"*/env/*",
"setup.py"
]
},
"lint_config": {
"enabled": true,
"max_line_length": 88,
"ignore": ["E203", "W503"]
}
}
Install the package:
pip install pyrulesrunner[all]
Create a testrules.json
configuration file in your project root:
{
"test_patterns": {
"unit": ["test_*.py", "*_test.py"],
"integration": ["integration_*.py"],
"e2e": ["e2e_*.py"]
},
"test_groups": {
"fast": ["test_utils", "test_models"],
"slow": ["test_integration", "test_e2e"]
},
"coverage_enabled": true,
"html_coverage": true
}
Run your tests:
# Run all tests
testrules
# Run only fast tests
testrules fast
# Run unit tests with coverage
testrules unit
# Run tests and linting
testrules check
🚀 Lightweight Test Runner
==================================================
📄 Loaded configuration from testrules.json
Command: all tests
🔍 Discovering tests...
📁 Found 4 test files
🧪 Discovering test methods...
🎯 Total test methods discovered: 15
🚀 Running tests...
📦 Running tests in module: test_calculator
[1/15] test_calculator.TestCalculator.test_add ... ✅ PASS (0.001s)
[2/15] test_calculator.TestCalculator.test_subtract ... ✅ PASS (0.001s)
============================================================
🧪 TEST SUMMARY
============================================================
✅ Passed: 14
❌ Failed: 1
💥 Errors: 0
📊 Total: 15
📈 Success Rate: 93.33%
⏱️ Execution Time: 0.05 seconds
📊 COVERAGE REPORT
============================================================
Name Stmts Miss Cover
----------------------------------------
calculator.py 20 2 90%
utils.py 15 0 100%
----------------------------------------
TOTAL 35 2 94%
✅ All checks passed successfully!
The test runner works with standard Python unittest framework:
import unittest
class TestExample(unittest.TestCase):
def test_addition(self):
"""Test basic addition."""
self.assertEqual(2 + 2, 4)
def test_subtraction(self):
"""Test basic subtraction."""
self.assertEqual(5 - 3, 2)
if __name__ == '__main__':
unittest.main()
test_*.py
, *_test.py
, unit_test_*.py
test_calculator.py
integration_test_*.py
, *_integration_test.py
integration_test_database.py
e2e_test_*.py
, *_e2e_test.py
e2e_test_user_registration.py
regression_test_*.py
, *_regression_test.py
regression_test_issue_123.py
You can also use the test runner programmatically:
from testrules import TestRunner, Config
# Create configuration
config = Config({
"test_patterns": {
"unit": ["test_*.py"]
},
"coverage_enabled": True
})
# Create and run test runner
runner = TestRunner(config)
test_results, coverage_obj = runner.run_tests(test_type="unit")
print(f"Tests run: {test_results.total}")
print(f"Passed: {test_results.passed}")
print(f"Failed: {test_results.failed}")
your_project/
├── testrules.json # Configuration file (optional)
├── src/ # Your source code
│ ├── module1.py
│ └── module2.py
├── tests/ # Your test files
│ ├── test_module1.py # Unit tests
│ ├── test_module2.py # Unit tests
│ ├── integration_test_api.py # Integration tests
│ ├── e2e_test_workflow.py # End-to-end tests
│ └── regression_test_bug_fix.py # Regression tests
└── htmlcov/ # HTML coverage reports (generated)
To contribute to the project:
git clone <repository-url>
cd pyrulesrunner
pip install -e .[dev]
# Run the test runner's own tests
testrules test_testrules
# Run all example tests
testrules comprehensive
coverage>=6.0
for coverage reportingflake8>=4.0
for lintingModule Import Errors
Coverage Not Working
pip install pyrulesrunner[coverage]
Linting Not Working
pip install pyrulesrunner[lint]
If you encounter issues:
This is a lightweight test runner designed for simplicity. If you need more advanced features, consider using pytest or other full-featured testing frameworks.
This project is open source under the MIT License. Feel free to modify and distribut
FAQs
A lightweight Python test runner with method-level discovery and coverage reporting
We found that pyrulesrunner demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.