Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@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')
@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
@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
@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)
@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)
@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
@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
@flaky
def test_install_without_dev(PipenvInstance, pypi):
"""Ensure that running `pipenv install` doesn't install dev packages"""
with PipenvInstance(pypi=pypi, chdir=True) as p:
with open(p.pipfile_path, "w") as f:
contents = """
[packages]
six = "*"
[dev-packages]
pytz = "*"
""".strip()
f.write(contents)
c = p.pipenv("install")
assert c.return_code == 0
assert "six" in p.pipfile["packages"]
assert "pytz" in p.pipfile["dev-packages"]
@flaky(3, 1)
@pytest.mark.timeout(10)
def test_error_send_empty_file(self, bot, chat_id):
with pytest.raises(TelegramError):
bot.send_video_note(chat_id, open(os.devnull, 'rb'))
@flaky(max_runs=3, rerun_filter=delay_rerun)
def test_single_editorial_review(self):
product = self.amazon.lookup(ItemId="1930846258")
expected = u'In the title piece, Alan Turing'
assert_equals(product.editorial_reviews[0][:len(expected)], expected)
assert_equals(product.editorial_review, product.editorial_reviews[0])
assert_equals(len(product.editorial_reviews), 1)