How to use flaky - 10 common examples

To help you get started, we’ve selected a few flaky examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github iterative / dvc / tests / func / test_repro.py View on Github external
p = Popen(
            "hadoop fs -copyFromLocal {} {}".format("tmp", url),
            shell=True,
            executable=os.getenv("SHELL"),
            stdin=PIPE,
            stdout=PIPE,
            stderr=PIPE,
        )
        out, err = p.communicate()
        if p.returncode != 0:
            print(out)
            print(err)
        self.assertEqual(p.returncode, 0)


@flaky(max_runs=3, min_passes=1)
class TestReproExternalSSH(TestReproExternalBase):
    _dir = None

    def should_test(self):
        return _should_test_ssh()

    @property
    def scheme(self):
        return "ssh"

    @property
    def bucket(self):
        if not self._dir:
            self._dir = TestDvc.mkdtemp()
        return "{}@127.0.0.1:{}".format(getpass.getuser(), self._dir)
github iterative / dvc / tests / func / test_repro.py View on Github external
p = Popen(
            "hadoop fs -copyFromLocal {} {}".format("tmp", url),
            shell=True,
            executable=os.getenv("SHELL"),
            stdin=PIPE,
            stdout=PIPE,
            stderr=PIPE,
        )
        out, err = p.communicate()
        if p.returncode != 0:
            print(out)
            print(err)
        self.assertEqual(p.returncode, 0)


@flaky(max_runs=3, min_passes=1)
class TestReproExternalSSH(TestReproExternalBase):
    _dir = None

    def should_test(self):
        return _should_test_ssh()

    @property
    def scheme(self):
        return "ssh"

    @property
    def bucket(self):
        if not self._dir:
            self._dir = TestDvc.mkdtemp()
        return "{}@127.0.0.1:{}".format(getpass.getuser(), self._dir)
github box / flaky / test / test_nose / test_flaky_nose_plugin.py View on Github external
def test_flaky_plugin_handles_bare_test(self):
        self._mock_test_names = self._mock_test_method_name
        self._mock_test.test = Mock()
        self._expect_call_test_address()
        attrib = defaults.default_flaky_attributes(2, 1)
        for name, value in attrib.items():
            setattr(
                self._mock_test.test,
                name,
                value,
            )
        delattr(self._mock_test, self._mock_test_method_name)
        self._flaky_plugin.prepareTestCase(self._mock_test_case)
        self.assertTrue(self._flaky_plugin.handleError(
            self._mock_test_case,
            self._mock_error,
        ))
        self.assertFalse(self._flaky_plugin.handleError(
            self._mock_test_case,
            self._mock_error,
        ))
github yoavaviram / python-amazon-simple-product-api / tests.py View on Github external
    @flaky(max_runs=3, rerun_filter=delay_rerun)
    def test_availability(self):
        product = self.amazon.lookup(ItemId="B00ZV9PXP2")
        assert_equals(product.availability, 'Usually ships in 24 hours')

        product = self.amazon.lookup(ItemId="1491914254") # pre-order book
        assert_equals(product.availability, 'Not yet published')
github pypa / pipenv / tests / integration / test_install_basic.py View on Github external
@flaky
def test_install_without_dev_section(PipenvInstance, pypi):
    with PipenvInstance(pypi=pypi) as p:
        with open(p.pipfile_path, "w") as f:
            contents = """
[packages]
six = "*"
            """.strip()
            f.write(contents)
        c = p.pipenv("install")
        assert c.return_code == 0
        assert "six" in p.pipfile["packages"]
        assert p.pipfile.get("dev-packages", {}) == {}
        assert "six" in p.lockfile["default"]
        assert p.lockfile["develop"] == {}
        c = p.pipenv('run python -c "import six"')
        assert c.return_code == 0
github python-telegram-bot / python-telegram-bot / tests / test_constants.py View on Github external
    @flaky(3, 1)
    @pytest.mark.timeout(10)
    def test_max_caption_length(self, bot, chat_id):
        good_caption = 'a' * constants.MAX_CAPTION_LENGTH
        with open('tests/data/telegram.png', 'rb') as f:
            good_msg = bot.send_photo(photo=f, caption=good_caption, chat_id=chat_id)
        assert good_msg.caption == good_caption

        bad_caption = good_caption + 'Z'
        with open('tests/data/telegram.png', 'rb') as f:
            bad_message = bot.send_photo(photo=f, caption=bad_caption, chat_id=chat_id)
        assert bad_message.caption != bad_caption
        assert len(bad_message.caption) == constants.MAX_CAPTION_LENGTH
github dmlc / gluon-nlp / tests / unittest / test_datasets.py View on Github external
@flaky(max_runs=2, min_passes=1)
@pytest.mark.serial
@pytest.mark.remote_required
@pytest.mark.skipif(datetime.date.today() < datetime.date(2019, 11, 21), reason='website down')
def test_semeval17task2():
    for segment, length in [("trial", 18), ("test", 500)]:
        data = nlp.data.SemEval17Task2(segment=segment)
        assert len(data) == length
        _assert_similarity_dataset(data)
github ethereum / web3.py / tests / core / filtering / test_contract_on_event_filtering.py View on Github external
@flaky(max_runs=3)
@pytest.mark.parametrize('call_as_instance', (True, False))
def test_on_filter_using_get_entries_interface(web3,
                                               sleep_interval,
                                               emitter,
                                               Emitter,
                                               wait_for_transaction,
                                               emitter_log_topics,
                                               emitter_event_ids,
                                               call_as_instance):
    if call_as_instance:
        filter = emitter.on('LogNoArguments', {})
    else:
        filter = Emitter.on('LogNoArguments', {})

    txn_hash = emitter.transact().logNoArgs(emitter_event_ids.LogNoArguments)
    wait_for_transaction(web3, txn_hash)
github python-telegram-bot / python-telegram-bot / tests / test_videonote.py View on Github external
    @flaky(3, 1)
    @pytest.mark.timeout(10)
    def test_send_all_args(self, bot, chat_id, video_note_file, video_note):
        message = bot.send_video_note(chat_id, video_note_file, duration=self.duration,
                                      length=self.length, disable_notification=False)

        assert isinstance(message.video_note, VideoNote)
        assert isinstance(message.video_note.file_id, str)
        assert message.video_note.file_id != ''
        assert message.video_note.length == video_note.length
        assert message.video_note.duration == video_note.duration
        assert message.video_note.file_size == video_note.file_size

        assert isinstance(message.video_note.thumb, PhotoSize)
        assert isinstance(message.video_note.thumb.file_id, str)
        assert message.video_note.thumb.file_id != ''
        assert message.video_note.thumb.width == video_note.thumb.width
github python-telegram-bot / python-telegram-bot / tests / test_voice.py View on Github external
    @flaky(3, 1)
    @pytest.mark.timeout(10)
    def test_resend(self, bot, chat_id, voice):
        message = bot.sendVoice(chat_id, voice.file_id)

        assert message.voice == voice