pytest-dev / pytest-repeat

pytest plugin for repeating test execution
https://pypi.python.org/pypi/pytest-repeat/
Other
169 stars 27 forks source link

Not support unittest #46

Closed Yanci516 closed 4 years ago

Yanci516 commented 4 years ago

My case is written in a class that inherits unittest.TestCase,I can use pytest to run。Now I want to use pytest-repeat(0.8.0) to satisfy my need for repetitive execution,but does not take effect。so can you support this scenario。Please see below:

import logging
import random
import time
from unittest import TestCase

import pytest

HANDLE = logging.StreamHandler()
HANDLE.setFormatter(logging.Formatter(
    '%(asctime)s - %(filename)s[line:%(lineno)d] - %(levelname)s: %(message)s'))
LOG = logging.getLogger(__name__)
LOG.setLevel(logging.DEBUG)
LOG.addHandler(HANDLE)

class Test(TestCase):
    @pytest.mark.repeat(3)
    def test_repeat_1(self):
        LOG.info("begin: " + time.strftime("%Y-%m-%d_%H:%M:%S"))
        time.sleep(random.randint(1, 4))
        LOG.info("end: " + time.strftime("%Y-%m-%d_%H:%M:%S"))

    @pytest.mark.repeat(3)
    def test_repeat_2(self):
        LOG.info("begin: " + time.strftime("%Y-%m-%d_%H:%M:%S"))
        time.sleep(random.randint(1, 4))
        LOG.info("end: " + time.strftime("%Y-%m-%d_%H:%M:%S"))

    @pytest.mark.repeat(3)
    def test_repeat_3(self):
        LOG.info("begin: " + time.strftime("%Y-%m-%d_%H:%M:%S"))
        time.sleep(random.randint(1, 4))
        LOG.info("end: " + time.strftime("%Y-%m-%d_%H:%M:%S"))
akx commented 4 years ago

This is currently not supported; do you see the warning in your console? https://github.com/pytest-dev/pytest-repeat/blob/c74dd59ebceda1c7963cde1935a57c498bc565bf/pytest_repeat.py#L42-L44

The-Compiler commented 4 years ago

See #3