python-telegram-bot/ptbcontrib

[QUESTION] Do I HAVE to do automatic tests?

bqback opened this issue · 2 comments

Pytest is moon runes to me and other files in ptbcontrib/tests or guides on the internet don't exactly make it much clearer how I would go about setting up a test file for my branch.
I have a working .py bot file that makes full use of my contribution (it's just a subclass with an additional attribute so not much space to mess things up) and it works just fine, can I just include it with the token omitted instead?

Hey. Our test suites serve (at least) two purposes:

  1. They provide an additional indication that a pull request acutally does what it promises - the reviewer might overlook a bug, which the tests hopefully catch
  2. They prevent regression: E.g. when functionality is expanded, the tests make sure that the currently available functionality still works

Of course for ptbcontrib this is less serious than for PTB itself, but we still expect contributions to provide at least some tests. The very minimal skeleton for a test file is also rather straight forward:

class TestMyContrib:  # class name must start wirt `Test`
    def test_one_thing(self):  # function name must start with `test`
        # do some stuff with your contribution
        assert expression  # where bool(expression) is expected to be True

    def test_another_thing(self):
        # do some stuff with your contribution
        assert expression  # where bool(expression) is expected to be True

If you have a contribution that you would like to share with ptbcontrib, feel free to open a PR. We can then have a look at what should be tested and how that can be done.

stale commented

This issue has been automatically closed due to inactivity. Feel free to comment in order to reopen or ask again in our Telegram support group at https://t.me/pythontelegrambotgroup.