Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[REFACTOR] Split test classes into two: TestXXXNoRequest & TestXXXRequest #3407

Closed
@harshil21

Description

@harshil21

Currently each of our test files has about one TestClass, which tests everything about the class together. This is not optimal because:

  1. Some tests in the class make actual requests to Telegram, thus slowing down development if you've made substantial changes to the class, but don't actually want to test the request part yet.
  2. It makes the tests slightly more readable, bearable and just a bit more organized.

Implementation

For example, test_sticker.py should now look like:

class StickerSpace:  # namespace class
     emoji = "💪🏽 "
     ...

@pytest.mark.no_req   # for faster development cycle
class TestStickerNoRequest:
    def test_de_json(...):
        ...
    def test_a_mock_request(...):
        ...

@pytest.mark.req  # don't think we need this, but let me know if you'd like this
@pytest.mark.flaky(3, 1)
class TestStickerRequest:
    def test_custom_emoji(...):
        await bot.get_sticker_set(...)

Along with this change, I'll also try to simplify/shorten some tests, if possible.

Metadata

Metadata

Assignees

Labels

⚙️ testsaffected functionality: tests🛠 refactorchange type: refactor

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions