> For the complete documentation index, see [llms.txt](https://docs.testfiesta.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.testfiesta.com/automation/testing-tools/python/pytest.md).

# Pytest

<figure><img src="/files/JgAbkGRrnuB3OhB8XbR0" alt="" width="375"><figcaption></figcaption></figure>

The `pytest` framework makes it easy to write small, readable tests, and can scale to support complex functional testing for applications and libraries. pytest unit  can  generate standard format JUnit-style XML files  which can be  submited  to Testfiesta or Testrail using taco truck cli. You just need to install the popular [`pytest`](https://docs.pytest.org/en/stable/getting-started.html) , and install Tacotruck CLI or use [Github action](https://github.com/testfiesta/tacotruck-action).  Check out simple pytest [example](https://github.com/testfiesta/tacotruck-examples/tree/main/demo-pytest-tf).

### Configuration

To generate xml file, report  file path should be included in command.

```sh
pytest --junitxml=test-results.xml
```

### Install Tacotruck CLI

{% code overflow="wrap" fullWidth="false" %}

```sh
$ npm install -g @testfiesta/tacotruck
```

{% endcode %}

### Submit test results

{% tabs %}
{% tab title="Testfiesta" %}

```sh
tacotruck testfiesta \
  run:submit \
  --token testfiesta_... \
  --handle orgHandle \
  --project projectKey \
  --name runName \
  --data results-path/*.xml
```

{% endtab %}
{% endtabs %}

### Github Action

{% tabs %}
{% tab title="Testfiesta" %}

```yaml
name: Python Tests
on:
  pull_request:
    branches:
      - main
  push:
    branches:
      - main
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: 📦 Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: "3.12"

      - name: 📦 Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install -r requirements.txt

      - name: 🧪 Run tests
        run: |
          pytest --junitxml=test-results.xml

      - name: Upload test results
        uses: actions/upload-artifact@v4
        with:
          name: pytest-results
          path: test-results.xml
        if: always()

      - name: Report Results
        uses: testfiesta/tacotruck-action@v1
        with:
          provider: testfiesta

```

{% endtab %}
{% endtabs %}

### Support and Resources

* [TacoTruck Examples](https://github.com/testfiesta/tacotruck-examples)
* [Pytest Docs](https://docs.pytest.org/en/stable/contents.html)
* [Tacotruck Issues](https://github.com/testfiesta/tacotruck/issues)
* [**CLI Reference**](/automation/tacotruck-cli.md)
* [Tacotruck Github Action](https://github.com/testfiesta/tacotruck-action)
