From 7b9d6af5a1d394dea678b45ea40ef321d00d301d Mon Sep 17 00:00:00 2001 From: Bernd Worsch Date: Tue, 23 Sep 2025 01:40:37 +0200 Subject: [PATCH] fix: Python 3.6 compatibility for tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Replace walrus operator (:=) with traditional assignment in config.py - Replace datetime.fromisoformat() with strptime() for Python 3.6 - Replace subprocess capture_output and text params with PIPE and universal_newlines - All tests now pass on Python 3.6.9 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- tddai/config.py | 12 ++++++++---- tddai/issue_fetcher.py | 15 +++++++++------ tddai/workspace.py | 2 +- tests/test_issue_11_workflow_integration.py | 5 +++-- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/tddai/config.py b/tddai/config.py index 7a8a4a1b..cba5a3eb 100644 --- a/tddai/config.py +++ b/tddai/config.py @@ -46,16 +46,20 @@ class TddaiConfig: config = cls() # Override with environment variables if present - if gitea_url := os.getenv("TDDAI_GITEA_URL"): + gitea_url = os.getenv("TDDAI_GITEA_URL") + if gitea_url: config.gitea_url = gitea_url - if repo_owner := os.getenv("TDDAI_REPO_OWNER"): + repo_owner = os.getenv("TDDAI_REPO_OWNER") + if repo_owner: config.repo_owner = repo_owner - if repo_name := os.getenv("TDDAI_REPO_NAME"): + repo_name = os.getenv("TDDAI_REPO_NAME") + if repo_name: config.repo_name = repo_name - if workspace_dir := os.getenv("TDDAI_WORKSPACE_DIR"): + workspace_dir = os.getenv("TDDAI_WORKSPACE_DIR") + if workspace_dir: config.workspace_dir = Path(workspace_dir) return config diff --git a/tddai/issue_fetcher.py b/tddai/issue_fetcher.py index 14d83cf4..7791fd2e 100644 --- a/tddai/issue_fetcher.py +++ b/tddai/issue_fetcher.py @@ -4,6 +4,7 @@ Issue fetching from Gitea API. import json import subprocess +from subprocess import PIPE from dataclasses import dataclass from datetime import datetime from typing import List, Optional, Dict, Any @@ -42,8 +43,9 @@ class IssueFetcher: try: result = subprocess.run( ['curl', '-s', f"{self.config.issues_api_url}/{issue_number}"], - capture_output=True, - text=True, + stdout=PIPE, + stderr=PIPE, + universal_newlines=True, check=True ) @@ -71,8 +73,9 @@ class IssueFetcher: result = subprocess.run( ['curl', '-s', url], - capture_output=True, - text=True, + stdout=PIPE, + stderr=PIPE, + universal_newlines=True, check=True ) @@ -111,8 +114,8 @@ class IssueFetcher: title=issue_data['title'], body=issue_data.get('body', ''), state=issue_data['state'], - created_at=datetime.fromisoformat(issue_data['created_at'].replace('Z', '+00:00')), - updated_at=datetime.fromisoformat(issue_data['updated_at'].replace('Z', '+00:00')), + created_at=datetime.strptime(issue_data['created_at'].replace('Z', '').split('.')[0], '%Y-%m-%dT%H:%M:%S'), + updated_at=datetime.strptime(issue_data['updated_at'].replace('Z', '').split('.')[0], '%Y-%m-%dT%H:%M:%S'), html_url=issue_data['html_url'], assignee=assignee, labels=labels diff --git a/tddai/workspace.py b/tddai/workspace.py index f8b3da53..ebab526a 100644 --- a/tddai/workspace.py +++ b/tddai/workspace.py @@ -83,7 +83,7 @@ class WorkspaceManager: issue_title=issue_data['title'], issue_body=issue_data['body'], issue_state=issue_data['state'], - created_at=datetime.fromisoformat(issue_data['created_at']), + created_at=datetime.strptime(issue_data['created_at'].replace('Z', '').split('.')[0], '%Y-%m-%dT%H:%M:%S'), workspace_dir=self.config.workspace_dir ) except (json.JSONDecodeError, KeyError, ValueError) as e: diff --git a/tests/test_issue_11_workflow_integration.py b/tests/test_issue_11_workflow_integration.py index 1116bae4..9bae9e22 100644 --- a/tests/test_issue_11_workflow_integration.py +++ b/tests/test_issue_11_workflow_integration.py @@ -9,6 +9,7 @@ This test validates issue #11: Setup TDD workspace infrastructure import pytest import subprocess +from subprocess import PIPE import tempfile import shutil from pathlib import Path @@ -32,7 +33,7 @@ class TestWorkflowIntegration: def test_make_tdd_status_command(self): """Test that make tdd-status command works correctly.""" result = subprocess.run(['make', 'tdd-status'], - capture_output=True, text=True) + stdout=PIPE, stderr=PIPE, universal_newlines=True) assert result.returncode == 0, "tdd-status command should succeed" # Should show clean workspace when no active workspace @@ -42,7 +43,7 @@ class TestWorkflowIntegration: def test_make_tdd_add_test_command_without_workspace(self): """Test that make tdd-add-test provides proper error when no workspace.""" result = subprocess.run(['make', 'tdd-add-test'], - capture_output=True, text=True) + stdout=PIPE, stderr=PIPE, universal_newlines=True) assert result.returncode != 0, "tdd-add-test command should fail when no workspace" assert "No active issue workspace" in result.stdout