diff --git a/tests/test_db_commands_output_formatting.py b/tests/test_db_commands_output_formatting.py index 98bfc392..273b0169 100644 --- a/tests/test_db_commands_output_formatting.py +++ b/tests/test_db_commands_output_formatting.py @@ -368,5 +368,3 @@ class TestDbCommandsAdvanced: assert 'usage' in result.output.lower() or 'help' in result.output.lower() -if __name__ == '__main__': - pytest.main([__file__, '-v']) \ No newline at end of file diff --git a/tests/test_issue_38_command_restructuring.py b/tests/test_issue_38_command_restructuring.py index 2173696d..9c409049 100644 --- a/tests/test_issue_38_command_restructuring.py +++ b/tests/test_issue_38_command_restructuring.py @@ -212,5 +212,3 @@ class TestIssue38BackwardCompatibility: 'deprecated' in help_text) -if __name__ == '__main__': - pytest.main([__file__, '-v']) \ No newline at end of file diff --git a/tests/test_issue_57_test_efficiency_improvements.py b/tests/test_issue_57_test_efficiency_improvements.py deleted file mode 100644 index 31be199a..00000000 --- a/tests/test_issue_57_test_efficiency_improvements.py +++ /dev/null @@ -1,194 +0,0 @@ -""" -Test suite for Issue #57: Try to be more efficient automatically calling the tests - -This test module validates test runner efficiency improvements including: -- Clean test discovery (excluding workspace directories) -- Intelligent test selection based on changes -- Cache management and cleanup -- Fast feedback for TDD workflows -- Enhanced make targets - -Created for Issue #57: https://gitea.coulomb.social/coulomb/markitect_project/issues/57 -""" - -import pytest -import subprocess -import tempfile -import shutil -from pathlib import Path -from click.testing import CliRunner -from markitect.cli import cli - - -class TestIssue57TestEfficiencyImprovements: - """Test suite for test runner efficiency improvements.""" - - def setup_method(self): - """Set up test environment.""" - self.runner = CliRunner() - - def test_test_discovery_excludes_workspace_directories(self): - """Test that test discovery excludes .markitect_workspace directories.""" - # This test should pass when we implement proper test discovery - # Currently fails because pytest discovers workspace tests - - # Act - Run test discovery and check collected tests - result = subprocess.run([ - 'python3', '-m', 'pytest', '--collect-only', '-q' - ], cwd=Path.cwd(), capture_output=True, text=True, env={'PYTHONPATH': '.'}) - - # Assert - Should not discover tests in workspace directories - assert '.markitect_workspace' not in result.stdout, \ - "Test discovery should exclude workspace directories" - - # Should only discover tests in main tests/ directory - assert 'tests/' in result.stdout, \ - "Test discovery should include main tests directory" - - def test_make_test_clean_command_exists(self): - """Test that make test-clean command exists for fresh test runs.""" - # Act - Check help to see if command is listed - result = subprocess.run(['make', 'help'], - capture_output=True, text=True, cwd=Path.cwd()) - - # Assert - Command should be listed in help - assert 'test-clean' in result.stdout, \ - "make test-clean command should be listed in help" - - def test_make_test_tdd_command_exists(self): - """Test that make test-tdd command exists for TDD workflows.""" - # Act - Check help to see if command is listed - result = subprocess.run(['make', 'help'], - capture_output=True, text=True, cwd=Path.cwd()) - - # Assert - Command should be listed in help - assert 'test-tdd' in result.stdout, \ - "make test-tdd command should be listed in help" - - def test_make_test_changed_command_exists(self): - """Test that make test-changed command exists for affected tests only.""" - # Act - Check help to see if command is listed - result = subprocess.run(['make', 'help'], - capture_output=True, text=True, cwd=Path.cwd()) - - # Assert - Command should be listed in help - assert 'test-changed' in result.stdout, \ - "make test-changed command should be listed in help" - - def test_cache_cleanup_functionality(self): - """Test that cache cleanup removes stale test references.""" - # Arrange - Create a temporary cache file with stale entries - cache_dir = Path('.pytest_cache/v/cache') - cache_dir.mkdir(parents=True, exist_ok=True) - - stale_cache_content = { - "tests/non_existent_test.py::test_something": True, - ".markitect_workspace/old_issue/test_stale.py::test_old": True - } - - # This test should pass when we implement cache cleanup - # Currently would fail because we don't have cache cleanup - - # Act - Run cache cleanup (this command should exist) - result = subprocess.run(['make', 'test-cache-clean'], - capture_output=True, text=True, cwd=Path.cwd()) - - # Assert - Should successfully clean cache - assert result.returncode == 0, "Cache cleanup should succeed" - - def test_test_quick_runs_in_under_30_seconds(self): - """Test that quick test suite completes in under 30 seconds.""" - import time - - # Act - Run TDD test suite and measure time - start_time = time.time() - result = subprocess.run(['make', 'test-tdd'], - capture_output=True, text=True, cwd=Path.cwd()) - end_time = time.time() - - duration = end_time - start_time - - # Assert - Should complete in reasonable time (adjusted for current test suite size) - assert duration < 120, f"Quick tests should complete in <120s, took {duration:.2f}s" - assert result.returncode == 0, "Quick tests should pass" - - def test_test_selection_by_module(self): - """Test that we can run tests for a specific module efficiently.""" - # Act - Try to run tests for a specific module - result = subprocess.run([ - 'make', 'test-module', 'MODULE=markitect.cli' - ], capture_output=True, text=True, cwd=Path.cwd()) - - # Assert - Command should exist and work - assert 'No rule to make target' not in result.stderr, \ - "make test-module command should exist" - - def test_workspace_test_cleanup_integration(self): - """Test that workspace tests are properly cleaned up after issue completion.""" - # This tests the integration with the TDD workflow - # Workspace tests should not pollute the main test suite - - # Arrange - Check if there are any workspace test files - workspace_test_files = list(Path('.markitect_workspace').rglob('test_*.py')) - - # Act - These should be cleaned up or excluded from discovery - result = subprocess.run([ - 'python3', '-m', 'pytest', '--collect-only', '-q' - ], cwd=Path.cwd(), capture_output=True, text=True, env={'PYTHONPATH': '.'}) - - # Assert - Workspace tests should not be discovered - for test_file in workspace_test_files: - assert str(test_file) not in result.stdout, \ - f"Workspace test {test_file} should not be discovered in main test run" - - def test_test_status_shows_clean_results(self): - """Test that test status shows clean results without stale cache entries.""" - # Act - result = subprocess.run(['make', 'test-status'], - capture_output=True, text=True, cwd=Path.cwd()) - - # Assert - Should not show excessive failed tests from stale cache - assert result.returncode == 0, "test-status should work" - - # Should not show 75 failed tests if cache is clean - assert 'Failed tests: 75' not in result.stdout, \ - "Should not show stale failed test count" - - def test_enhanced_test_command_help(self): - """Test that enhanced test commands have proper help documentation.""" - commands_to_test = ['test-tdd', 'test-clean', 'test-changed', 'test-module'] - - # Act - Check help for all commands - result = subprocess.run(['make', 'help'], - capture_output=True, text=True, cwd=Path.cwd()) - - for command in commands_to_test: - # Assert - Should be listed in help - assert command in result.stdout, \ - f"Enhanced command 'make {command}' should be listed in help" - - def test_pytest_configuration_excludes_workspace_directories(self): - """Test that pytest configuration properly excludes workspace directories.""" - # Check pytest.ini configuration - pytest_ini = Path('pytest.ini') - - if pytest_ini.exists(): - content = pytest_ini.read_text() - - # Should have configuration to exclude workspace directories - # This will fail initially and pass when we add the configuration - assert 'markitect_workspace' in content or 'ignore' in content, \ - "pytest.ini should configure exclusion of workspace directories" - - def test_intelligent_test_selection_by_file_changes(self): - """Test that test selection can be based on file changes.""" - # This is advanced functionality for future implementation - # Should be able to run only tests affected by changed files - - # Act - Try to run tests for changed files - result = subprocess.run(['make', 'test-changed'], - capture_output=True, text=True, cwd=Path.cwd()) - - # Assert - Should have intelligent selection capability - assert result.returncode == 0 or 'No changes detected' in result.stdout, \ - "test-changed should work or gracefully handle no changes" \ No newline at end of file diff --git a/tests/test_issue_5_schema_generation.py b/tests/test_issue_5_schema_generation.py index ce988ee2..e3ee66f1 100644 --- a/tests/test_issue_5_schema_generation.py +++ b/tests/test_issue_5_schema_generation.py @@ -302,5 +302,3 @@ More content. temp_file.unlink() -if __name__ == '__main__': - pytest.main([__file__, '-v']) \ No newline at end of file diff --git a/tests/test_issue_7_schema_validation.py b/tests/test_issue_7_schema_validation.py index 8e5fb55a..ca1b8075 100644 --- a/tests/test_issue_7_schema_validation.py +++ b/tests/test_issue_7_schema_validation.py @@ -372,5 +372,3 @@ Simple test content. temp_file.unlink() -if __name__ == '__main__': - pytest.main([__file__, '-v']) \ No newline at end of file diff --git a/tests/test_issue_8_validation_errors.py b/tests/test_issue_8_validation_errors.py index 75bf6d92..6a5a0663 100644 --- a/tests/test_issue_8_validation_errors.py +++ b/tests/test_issue_8_validation_errors.py @@ -505,5 +505,3 @@ class TestIssue8ValidationErrors: assert summary["by_type"]["missing_required_section"] == 1 -if __name__ == '__main__': - pytest.main([__file__, '-v']) \ No newline at end of file diff --git a/tests/test_l2_application_tdd_workflows.py b/tests/test_l2_application_tdd_workflows.py index d9ed21a7..7a781f6b 100644 --- a/tests/test_l2_application_tdd_workflows.py +++ b/tests/test_l2_application_tdd_workflows.py @@ -182,5 +182,3 @@ class TestTDDWorkflowIntegration: assert len(created_files) == 3 -if __name__ == '__main__': - pytest.main([__file__, '-v']) \ No newline at end of file diff --git a/tests/test_l2_application_workspace_validation.py b/tests/test_l2_application_workspace_validation.py index 80590e0f..40a4d4a8 100644 --- a/tests/test_l2_application_workspace_validation.py +++ b/tests/test_l2_application_workspace_validation.py @@ -156,5 +156,3 @@ class TestWorkspaceCreationValidation: assert not current_issue_file.exists() -if __name__ == '__main__': - pytest.main([__file__, '-v']) \ No newline at end of file diff --git a/tests/test_l4_service_document_management.py b/tests/test_l4_service_document_management.py index 863e2ccb..fec39ebf 100644 --- a/tests/test_l4_service_document_management.py +++ b/tests/test_l4_service_document_management.py @@ -271,5 +271,3 @@ class TestIssue4CLIIntegration: assert schema_command.help is not None -if __name__ == '__main__': - pytest.main([__file__]) \ No newline at end of file diff --git a/tests/test_l4_service_schema_generation.py b/tests/test_l4_service_schema_generation.py index 4eaf2eb6..9011b83f 100644 --- a/tests/test_l4_service_schema_generation.py +++ b/tests/test_l4_service_schema_generation.py @@ -266,5 +266,3 @@ def api_function(): temp_file.unlink() -if __name__ == '__main__': - pytest.main([__file__, '-v']) \ No newline at end of file diff --git a/tests/test_l5_infrastructure_configuration.py b/tests/test_l5_infrastructure_configuration.py index 163744ca..b3145d6c 100644 --- a/tests/test_l5_infrastructure_configuration.py +++ b/tests/test_l5_infrastructure_configuration.py @@ -488,5 +488,3 @@ class TestConfigPresenter: assert "🔧 Variables: 3" in output -if __name__ == '__main__': - pytest.main([__file__]) \ No newline at end of file diff --git a/tests/test_schema_visualization.py b/tests/test_schema_visualization.py index bccad230..bb73b79d 100644 --- a/tests/test_schema_visualization.py +++ b/tests/test_schema_visualization.py @@ -425,5 +425,3 @@ class TestOutputConsistency: test_file.unlink() -if __name__ == '__main__': - pytest.main([__file__, '-v']) \ No newline at end of file