qastudio-pytest


Nameqastudio-pytest JSON
Version 1.0.2 PyPI version JSON
download
home_pageNone
Summarypytest plugin for QAStudio.dev test management platform
upload_time2025-11-02 20:49:01
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT
keywords pytest testing test-management qa qastudio
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # QAStudio pytest Plugin

A pytest plugin that integrates with [QAStudio.dev](https://qastudio.dev) test management platform.

## Features

- 🔄 Automatic test result reporting to QAStudio.dev
- 📊 Real-time test run tracking
- 🏷️ Test case linking via markers or test IDs
- 📸 Screenshot and attachment support
- 🔧 Configurable via pytest.ini, command line, or environment variables
- 🎯 Batch result submission for performance
- 🛡️ Silent mode - won't fail tests if API is unavailable
- 📝 Error code snippets with context around failure points
- 📍 Precise error location tracking (file, line, column)
- 📤 Console output capture (stdout/stderr)
- 🔍 Enhanced debugging context for test failures

## Installation

```bash
pip install qastudio-pytest
```

## Quick Start

### 1. Configure via pytest.ini

```ini
[pytest]
qastudio_api_url = https://qastudio.dev/api
qastudio_api_key = your-api-key
qastudio_project_id = your-project-id
qastudio_environment = CI
```

### 2. Configure via Environment Variables

```bash
export QASTUDIO_API_URL=https://qastudio.dev/api
export QASTUDIO_API_KEY=your-api-key
export QASTUDIO_PROJECT_ID=your-project-id
export QASTUDIO_ENVIRONMENT=CI
```

### 3. Configure via Command Line

```bash
pytest --qastudio-api-url=https://qastudio.dev/api \
       --qastudio-api-key=your-api-key \
       --qastudio-project-id=your-project-id
```

## Usage

### Linking Tests to QAStudio Test Cases

#### Method 1: Using pytest markers

```python
import pytest

@pytest.mark.qastudio_id("QA-123")
def test_login():
    assert user.login("user", "pass")
```

#### Method 2: Using test ID in test name

```python
def test_QA123_login():
    """Test case QA-123"""
    assert user.login("user", "pass")
```

#### Method 3: Using docstring

```python
def test_login():
    """
    Test user login functionality

    QAStudio ID: QA-123
    """
    assert user.login("user", "pass")
```

### Adding Custom Metadata

```python
import pytest

@pytest.mark.qastudio_id("QA-456")
@pytest.mark.qastudio_priority("high")
@pytest.mark.qastudio_tags("smoke", "authentication")
def test_important_feature():
    assert True
```

## Configuration Options

| Option | Environment Variable | Description | Default |
|--------|---------------------|-------------|---------|
| `qastudio_api_url` | `QASTUDIO_API_URL` | QAStudio.dev API URL | `https://qastudio.dev/api` |
| `qastudio_api_key` | `QASTUDIO_API_KEY` | API authentication key | Required |
| `qastudio_project_id` | `QASTUDIO_PROJECT_ID` | Project ID | Required |
| `qastudio_environment` | `QASTUDIO_ENVIRONMENT` | Environment name | `default` |
| `qastudio_test_run_name` | `QASTUDIO_TEST_RUN_NAME` | Custom test run name | Auto-generated |
| `qastudio_test_run_id` | `QASTUDIO_TEST_RUN_ID` | Existing test run ID | None |
| `qastudio_create_test_run` | `QASTUDIO_CREATE_TEST_RUN` | Create new test run | `true` |
| `qastudio_batch_size` | `QASTUDIO_BATCH_SIZE` | Results batch size | `10` |
| `qastudio_silent` | `QASTUDIO_SILENT` | Fail silently on API errors | `true` |
| `qastudio_verbose` | `QASTUDIO_VERBOSE` | Enable verbose logging | `false` |
| `qastudio_include_error_snippet` | `QASTUDIO_INCLUDE_ERROR_SNIPPET` | Include error code snippet | `true` |
| `qastudio_include_error_location` | `QASTUDIO_INCLUDE_ERROR_LOCATION` | Include precise error location | `true` |
| `qastudio_include_test_steps` | `QASTUDIO_INCLUDE_TEST_STEPS` | Include test execution steps | `true` |
| `qastudio_include_console_output` | `QASTUDIO_INCLUDE_CONSOLE_OUTPUT` | Include console output | `false` |

## Error Context and Debugging

The plugin automatically captures rich debugging context for failed tests:

### Error Code Snippets

When a test fails, the plugin captures the relevant code snippet showing where the error occurred:

```python
def test_calculation():
    result = calculate(5, 0)  # This line will be captured in the error snippet
    assert result == 10
```

Disable with:
```ini
[pytest]
qastudio_include_error_snippet = false
```

### Error Location

Precise error location information (file path, line number) is automatically captured:

```json
{
  "errorLocation": {
    "file": "tests/test_example.py",
    "line": 42,
    "column": 0
  }
}
```

Disable with:
```ini
[pytest]
qastudio_include_error_location = false
```

### Console Output

Capture stdout and stderr from test execution (disabled by default to avoid sensitive data):

```ini
[pytest]
qastudio_include_console_output = true
```

Or via command line:
```bash
pytest --qastudio-include-console-output
```

## Advanced Usage

### Using with pytest-xdist (Parallel Testing)

```bash
pytest -n auto --qastudio-api-key=your-api-key
```

The plugin handles parallel test execution automatically.

### CI/CD Integration

#### GitHub Actions

```yaml
- name: Run Tests
  run: |
    pytest --junitxml=report.xml
  env:
    QASTUDIO_API_KEY: ${{ secrets.QASTUDIO_API_KEY }}
    QASTUDIO_PROJECT_ID: ${{ secrets.QASTUDIO_PROJECT_ID }}
    QASTUDIO_ENVIRONMENT: CI
```

#### GitLab CI

```yaml
test:
  script:
    - pytest
  variables:
    QASTUDIO_API_KEY: $QASTUDIO_API_KEY
    QASTUDIO_PROJECT_ID: $QASTUDIO_PROJECT_ID
    QASTUDIO_ENVIRONMENT: CI
```

## Development

```bash
# Clone repository
git clone https://github.com/QAStudio-Dev/playwright-reporter-python.git
cd playwright-reporter-python

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install in development mode
pip install -e .[dev]

# Run tests
pytest tests/

# Run linting
black src/ tests/
flake8 src/ tests/
mypy src/

# Build package
python -m build
```

## License

MIT License - see [LICENSE](LICENSE) file for details.

## Support

- 📧 Email: ben@qastudio.dev
- 🐛 Issues: https://github.com/QAStudio-Dev/playwright-reporter-python/issues
- 📖 Documentation: https://qastudio.dev/docs

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "qastudio-pytest",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "pytest, testing, test-management, qa, qastudio",
    "author": null,
    "author_email": "QAStudio <ben@qastudio.dev>",
    "download_url": "https://files.pythonhosted.org/packages/5a/bc/d976649c3727d026fa6e15b01a5b8700231eb0a171ed78e8e562103f59d6/qastudio_pytest-1.0.2.tar.gz",
    "platform": null,
    "description": "# QAStudio pytest Plugin\n\nA pytest plugin that integrates with [QAStudio.dev](https://qastudio.dev) test management platform.\n\n## Features\n\n- \ud83d\udd04 Automatic test result reporting to QAStudio.dev\n- \ud83d\udcca Real-time test run tracking\n- \ud83c\udff7\ufe0f Test case linking via markers or test IDs\n- \ud83d\udcf8 Screenshot and attachment support\n- \ud83d\udd27 Configurable via pytest.ini, command line, or environment variables\n- \ud83c\udfaf Batch result submission for performance\n- \ud83d\udee1\ufe0f Silent mode - won't fail tests if API is unavailable\n- \ud83d\udcdd Error code snippets with context around failure points\n- \ud83d\udccd Precise error location tracking (file, line, column)\n- \ud83d\udce4 Console output capture (stdout/stderr)\n- \ud83d\udd0d Enhanced debugging context for test failures\n\n## Installation\n\n```bash\npip install qastudio-pytest\n```\n\n## Quick Start\n\n### 1. Configure via pytest.ini\n\n```ini\n[pytest]\nqastudio_api_url = https://qastudio.dev/api\nqastudio_api_key = your-api-key\nqastudio_project_id = your-project-id\nqastudio_environment = CI\n```\n\n### 2. Configure via Environment Variables\n\n```bash\nexport QASTUDIO_API_URL=https://qastudio.dev/api\nexport QASTUDIO_API_KEY=your-api-key\nexport QASTUDIO_PROJECT_ID=your-project-id\nexport QASTUDIO_ENVIRONMENT=CI\n```\n\n### 3. Configure via Command Line\n\n```bash\npytest --qastudio-api-url=https://qastudio.dev/api \\\n       --qastudio-api-key=your-api-key \\\n       --qastudio-project-id=your-project-id\n```\n\n## Usage\n\n### Linking Tests to QAStudio Test Cases\n\n#### Method 1: Using pytest markers\n\n```python\nimport pytest\n\n@pytest.mark.qastudio_id(\"QA-123\")\ndef test_login():\n    assert user.login(\"user\", \"pass\")\n```\n\n#### Method 2: Using test ID in test name\n\n```python\ndef test_QA123_login():\n    \"\"\"Test case QA-123\"\"\"\n    assert user.login(\"user\", \"pass\")\n```\n\n#### Method 3: Using docstring\n\n```python\ndef test_login():\n    \"\"\"\n    Test user login functionality\n\n    QAStudio ID: QA-123\n    \"\"\"\n    assert user.login(\"user\", \"pass\")\n```\n\n### Adding Custom Metadata\n\n```python\nimport pytest\n\n@pytest.mark.qastudio_id(\"QA-456\")\n@pytest.mark.qastudio_priority(\"high\")\n@pytest.mark.qastudio_tags(\"smoke\", \"authentication\")\ndef test_important_feature():\n    assert True\n```\n\n## Configuration Options\n\n| Option | Environment Variable | Description | Default |\n|--------|---------------------|-------------|---------|\n| `qastudio_api_url` | `QASTUDIO_API_URL` | QAStudio.dev API URL | `https://qastudio.dev/api` |\n| `qastudio_api_key` | `QASTUDIO_API_KEY` | API authentication key | Required |\n| `qastudio_project_id` | `QASTUDIO_PROJECT_ID` | Project ID | Required |\n| `qastudio_environment` | `QASTUDIO_ENVIRONMENT` | Environment name | `default` |\n| `qastudio_test_run_name` | `QASTUDIO_TEST_RUN_NAME` | Custom test run name | Auto-generated |\n| `qastudio_test_run_id` | `QASTUDIO_TEST_RUN_ID` | Existing test run ID | None |\n| `qastudio_create_test_run` | `QASTUDIO_CREATE_TEST_RUN` | Create new test run | `true` |\n| `qastudio_batch_size` | `QASTUDIO_BATCH_SIZE` | Results batch size | `10` |\n| `qastudio_silent` | `QASTUDIO_SILENT` | Fail silently on API errors | `true` |\n| `qastudio_verbose` | `QASTUDIO_VERBOSE` | Enable verbose logging | `false` |\n| `qastudio_include_error_snippet` | `QASTUDIO_INCLUDE_ERROR_SNIPPET` | Include error code snippet | `true` |\n| `qastudio_include_error_location` | `QASTUDIO_INCLUDE_ERROR_LOCATION` | Include precise error location | `true` |\n| `qastudio_include_test_steps` | `QASTUDIO_INCLUDE_TEST_STEPS` | Include test execution steps | `true` |\n| `qastudio_include_console_output` | `QASTUDIO_INCLUDE_CONSOLE_OUTPUT` | Include console output | `false` |\n\n## Error Context and Debugging\n\nThe plugin automatically captures rich debugging context for failed tests:\n\n### Error Code Snippets\n\nWhen a test fails, the plugin captures the relevant code snippet showing where the error occurred:\n\n```python\ndef test_calculation():\n    result = calculate(5, 0)  # This line will be captured in the error snippet\n    assert result == 10\n```\n\nDisable with:\n```ini\n[pytest]\nqastudio_include_error_snippet = false\n```\n\n### Error Location\n\nPrecise error location information (file path, line number) is automatically captured:\n\n```json\n{\n  \"errorLocation\": {\n    \"file\": \"tests/test_example.py\",\n    \"line\": 42,\n    \"column\": 0\n  }\n}\n```\n\nDisable with:\n```ini\n[pytest]\nqastudio_include_error_location = false\n```\n\n### Console Output\n\nCapture stdout and stderr from test execution (disabled by default to avoid sensitive data):\n\n```ini\n[pytest]\nqastudio_include_console_output = true\n```\n\nOr via command line:\n```bash\npytest --qastudio-include-console-output\n```\n\n## Advanced Usage\n\n### Using with pytest-xdist (Parallel Testing)\n\n```bash\npytest -n auto --qastudio-api-key=your-api-key\n```\n\nThe plugin handles parallel test execution automatically.\n\n### CI/CD Integration\n\n#### GitHub Actions\n\n```yaml\n- name: Run Tests\n  run: |\n    pytest --junitxml=report.xml\n  env:\n    QASTUDIO_API_KEY: ${{ secrets.QASTUDIO_API_KEY }}\n    QASTUDIO_PROJECT_ID: ${{ secrets.QASTUDIO_PROJECT_ID }}\n    QASTUDIO_ENVIRONMENT: CI\n```\n\n#### GitLab CI\n\n```yaml\ntest:\n  script:\n    - pytest\n  variables:\n    QASTUDIO_API_KEY: $QASTUDIO_API_KEY\n    QASTUDIO_PROJECT_ID: $QASTUDIO_PROJECT_ID\n    QASTUDIO_ENVIRONMENT: CI\n```\n\n## Development\n\n```bash\n# Clone repository\ngit clone https://github.com/QAStudio-Dev/playwright-reporter-python.git\ncd playwright-reporter-python\n\n# Create virtual environment\npython -m venv venv\nsource venv/bin/activate  # On Windows: venv\\Scripts\\activate\n\n# Install in development mode\npip install -e .[dev]\n\n# Run tests\npytest tests/\n\n# Run linting\nblack src/ tests/\nflake8 src/ tests/\nmypy src/\n\n# Build package\npython -m build\n```\n\n## License\n\nMIT License - see [LICENSE](LICENSE) file for details.\n\n## Support\n\n- \ud83d\udce7 Email: ben@qastudio.dev\n- \ud83d\udc1b Issues: https://github.com/QAStudio-Dev/playwright-reporter-python/issues\n- \ud83d\udcd6 Documentation: https://qastudio.dev/docs\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "pytest plugin for QAStudio.dev test management platform",
    "version": "1.0.2",
    "project_urls": {
        "Documentation": "https://github.com/QAStudio-Dev/playwright-reporter-python#readme",
        "Homepage": "https://github.com/QAStudio-Dev/playwright-reporter-python",
        "Issues": "https://github.com/QAStudio-Dev/playwright-reporter-python/issues",
        "Repository": "https://github.com/QAStudio-Dev/playwright-reporter-python"
    },
    "split_keywords": [
        "pytest",
        " testing",
        " test-management",
        " qa",
        " qastudio"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "b959bf064a8aa0ce52571345f84c2ccbe542d3aa746299c8d2ba288d32a6a091",
                "md5": "70cb471d457d8ae209081588f3ce5c80",
                "sha256": "e004978733261be4351a624715861855283637e0ec48b731638a8a595c3863d9"
            },
            "downloads": -1,
            "filename": "qastudio_pytest-1.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "70cb471d457d8ae209081588f3ce5c80",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 15261,
            "upload_time": "2025-11-02T20:49:00",
            "upload_time_iso_8601": "2025-11-02T20:49:00.185254Z",
            "url": "https://files.pythonhosted.org/packages/b9/59/bf064a8aa0ce52571345f84c2ccbe542d3aa746299c8d2ba288d32a6a091/qastudio_pytest-1.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "5abcd976649c3727d026fa6e15b01a5b8700231eb0a171ed78e8e562103f59d6",
                "md5": "211093139564698787ad79b4a6fd632e",
                "sha256": "6847d780dac3fae359a07d4c2f8517edf7f08b9915f313f3a0f10004bcc3c9f6"
            },
            "downloads": -1,
            "filename": "qastudio_pytest-1.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "211093139564698787ad79b4a6fd632e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 16685,
            "upload_time": "2025-11-02T20:49:01",
            "upload_time_iso_8601": "2025-11-02T20:49:01.480062Z",
            "url": "https://files.pythonhosted.org/packages/5a/bc/d976649c3727d026fa6e15b01a5b8700231eb0a171ed78e8e562103f59d6/qastudio_pytest-1.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-11-02 20:49:01",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "QAStudio-Dev",
    "github_project": "playwright-reporter-python#readme",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "qastudio-pytest"
}
        
Elapsed time: 4.92845s