Skip to content

Commit 49c7d7c

Browse files
committed
Fix Python import issues in tests
- Update PYTHONPATH in GitHub Actions to include project root - Add conftest.py to help with test imports - Use relative imports in src/__init__.py - Add noqa comment to test imports - Use python -m pytest to ensure correct import paths
1 parent d0717ba commit 49c7d7c

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ jobs:
7373
7474
- name: Test with pytest
7575
env:
76-
PYTHONPATH: src
76+
PYTHONPATH: ${{ github.workspace }}
7777
run: |
78-
pytest tests/ --cov=src --cov-report=xml --cov-report=term-missing
78+
python -m pytest tests/ --cov=src --cov-report=xml --cov-report=term-missing
7979
8080
- name: Upload coverage to Codecov
8181
uses: codecov/codecov-action@v3

src/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
__author__ = "Josh Simnitt"
1010
__email__ = "josh.simnitt@example.com"
1111

12-
from src.config import jira_config, app_config
13-
from src.models import JiraIssueData, JiraSubtaskData, CSVRow
14-
from src.jira_client import JiraClient
15-
from src.csv_processor import CSVProcessor
12+
from .config import jira_config, app_config
13+
from .models import JiraIssueData, JiraSubtaskData, CSVRow
14+
from .jira_client import JiraClient
15+
from .csv_processor import CSVProcessor
1616

1717
__all__ = [
1818
"jira_config",

tests/conftest.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import os
2+
import sys
3+
4+
# Add the project root directory to the Python path
5+
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))

tests/test_improved_modules.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"atlassian.errors": Mock(),
1717
},
1818
):
19-
from src.config import JiraConfig, AppConfig
19+
from src.config import JiraConfig, AppConfig # noqa
2020
from src.models import JiraIssueData, JiraSubtaskData, CSVRow
2121
from src.csv_processor import CSVProcessor
2222
from src.jira_client import JiraClient

0 commit comments

Comments
 (0)