Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/0xsirsaif/pytest-frappe
A set of pytest fixtures to test Frappe applications
https://github.com/0xsirsaif/pytest-frappe
erpnext frappe frappe-framework pytest pytest-plugin python test unit-testing
Last synced: 4 days ago
JSON representation
A set of pytest fixtures to test Frappe applications
- Host: GitHub
- URL: https://github.com/0xsirsaif/pytest-frappe
- Owner: 0xsirsaif
- License: mit
- Created: 2023-04-14T11:35:25.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-07-30T10:41:35.000Z (3 months ago)
- Last Synced: 2024-10-25T12:38:08.021Z (11 days ago)
- Topics: erpnext, frappe, frappe-framework, pytest, pytest-plugin, python, test, unit-testing
- Language: Python
- Homepage:
- Size: 24.4 KB
- Stars: 10
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pytest-frappe
`pytest-frappe` is a set of pytest fixtures for testing Frappe applications. It provides two fixtures: `db_instance` and `db_transaction`, which can be used to create and manage database connections.
## Installation
You can install `pytest-frappe` via pip:
```bash
pip install pytest-frappe
```## Usage
To use the fixtures provided by `pytest-frappe`
```python
def test_foo(db_transaction):
# use the db_instance fixture to interact with the database
pass
````pytest-frappe` also provides a command line option, `--sites-path`, which can be used to specify the directory where your Frappe sites are stored. This option is required to initialize the `db_instance` fixture.
Here's an example of how you can use the `--sites-path` option:
```bash
pytest --sites-path=/path/to/sites/directory
```## Available fixtures
### `db_instance`
The `db_instance` fixture provides a database connection to a Frappe application. It is created at the beginning of the test session and destroyed at the end of the session. This fixture is used to perform database operations.
### `db_transaction`
The `db_transaction` fixture is a database transaction context manager. It creates a new transaction at the beginning of each test function and rolls back the transaction at the end of the test function. This fixture is used to perform database operations within a transaction.
## License
`pytest-frappe` is licensed under the MIT License. See LICENSE for more information.