semvec/pypi-packages huggingface dataset:
pytest-smtp-test-server 0.1.1
pytest plugin for using `smtp-test-server` as a fixture
License: MIT
Requires Python: >=3.11,<4.0
Keywords: py.test,pytest,pytest-plugin,mail,smtp,mock,fixture

# pytest-smtp-test-server

pytest plugin for using [`smtp-test-server`](https://git.codebau.dev/jed/smtp-test-server) as pytest mock fixtures.

## Installation

### Installation with "pip"

```Bash
pip install pytest-smtp-test-server
```

### Installation with "poetry"

```Bash
poetry add --group dev pytest-smtp-test-server
```

## Usage

After installation, one could easily use one of the provided fixtures in your pytest test case:

```Python
def test_mail_sending(smtp_mock):
    my_mail_sending_method(host=smtp_mock.host, port=smtp_mock.port)
    assert len(smtp_mock.messages) == 1
```

## Scopes

Fixtures are provided for different [pytest fixture scopes](https://docs.pytest.org/en/stable/explanation/fixtures.html)
for your convenience:

| fixture name          | pytest fixture scope |
|-----------------------|----------------------|
| `smtp_mock`           | function             |
| `class_smtp_mock`     | class                |
| `module_smtp_mock`    | module               |
| `package_smtp_mock`   | package              |
| `session_smtp_mock`   | session              |

If you require more control over hosts and ports, consider using
[`smtp-test-server`](https://git.codebau.dev/jed/smtp-test-server) directly.
smtp-test-server 0.1.0
Simple SMTP test server for running unit and integration tests.
License: MIT
Requires Python: >=3.11,<4.0
Keywords: test,unittest,integrationtest,mail,smtp,mock

# smtp-test-server

Based on the [`aiosmtpd`](https://github.com/aio-libs/aiosmtpd), this packages offers you a simple way to integrate
a SMTP server into your test code.

Currently, the server does not support authentication, TLS or anything special instead of sending mails.

All mails are collected in the `messages` property of the mock and can be evaluated there.

Looking for a `pytest` SMTP mock fixture? Take a look at this project:
[git.codebau.dev/pytest-plugins/pytest-smtp-test-server](https://git.codebau.dev/pytest-plugins/pytest-smtp-test-server).

## Installation

### Installation with "pip"

```Bash
pip install smtp-test-server
```

### Installation with "poetry"

```Bash
poetry add --group dev smtp-test-server
```

## Usage

Simple usage, with auto assigning a free port number on `127.0.0.1`:

```Python
from smtp_test_server.context import SmtpMockServer

def test_send_mail():
    with SmtpMockServer() as smtp_mock:
        my_mail_method(smtp_host=smtp_mock.host, smtp_port=smtp_mock.port)
    assert len(smtp_mock.messages) == 1
    assert smtp_mock.messages[0]["from"] == "my-test@sender.org"
```

Want to have more control over host and port? Use it like this:

```Python
with SmtpMockServer(bind_host="223.12.9.177", bind_port=2525):
    ...
```

Ports are automatically closed when leaving the context.