jaraco / irc

Full-featured Python IRC library for Python.
MIT License
390 stars 84 forks source link

Create pytest fixtures for integration tests #143

Open jaraco opened 6 years ago

jaraco commented 6 years ago

I imagine one could create a pytest fixture, one which starts the server and provides convenience functions for common assertions, such that a test could look something like:

def test_server_receives_message(irc_server):
    client = irc_server.get_client(nick=’test_user')
    client.pubmesg(“#test-channel”, “Hello message”)
    assert irc_server.get_last_message().nick == ‘test_user’
    assert irc_server.get_last_message().type == ‘pubmsg’
    assert irc_server.get_last_message().message_text.startswith(“Hello”)

Note, that is not a spec, but more of a sketch of the idea. The actual interface would need to use names and methods that match the spec/implementation.

The test would be exposed through entry points such that the mere presence of this irc library in the test environment would make that fixture available.