fix: Python 3.6 compatibility for tests

- 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 <noreply@anthropic.com>
This commit is contained in:
2025-09-23 01:40:37 +02:00
parent 7bdc21d3ef
commit 7b9d6af5a1
4 changed files with 21 additions and 13 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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:

View File

@@ -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