Configure Pytest discovery to ignore class name

后端 未结 5 897
生来不讨喜
生来不讨喜 2021-01-11 14:16

Pytest\'s default discovery rules will import all Class starting with Test that do not have an __init__(). I have a situation where this causes an

5条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-11 14:31

    Here is a simple solution that I use, but has some overhead.

    class DisablePyTestCollectionMixin(object):
      __test__ = False
    
    class TestimonialFactory(DisablePyTestCollectionMixin):
      pass
    

    Based on: https://github.com/pytest-dev/pytest/issues/1879

提交回复
热议问题