fix: resolve cross-platform test failures on Windows and Ubuntu

- Add proper cross-platform path handling with Path.resolve()
- Fix file encoding issues by explicitly using UTF-8
- Correct mock paths to use google.generativeai instead of gemini_server.genai
- Create setup.py for proper package installation in CI
- Add conftest.py with Windows asyncio compatibility
- Update CI workflow to install package with pip install -e .
- Add import tests to verify package installation
- Set PYTHONPATH in test environment
- Simplify import mechanism in tests

These changes ensure tests pass consistently across Windows, Ubuntu, and macOS platforms.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Fahad
2025-06-08 20:42:59 +04:00
parent 970b73c175
commit 1d217ca397
5 changed files with 103 additions and 31 deletions

View File

@@ -25,14 +25,16 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade pip setuptools wheel
pip install -e .
pip install -r requirements.txt
- name: Run tests with pytest
env:
GEMINI_API_KEY: "dummy-key-for-tests"
PYTHONPATH: ${{ github.workspace }}
run: |
pytest tests/ -v --cov=gemini_server --cov-report=xml --cov-report=term
python -m pytest tests/ -v --cov=gemini_server --cov-report=xml --cov-report=term -x
- name: Upload coverage to Codecov
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
@@ -56,7 +58,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade pip setuptools wheel
pip install flake8 black isort mypy
pip install -r requirements.txt