Best Python code snippet using tempest_python
test_oracle.py
Source:test_oracle.py
2from .oracle import detect_cipher, encryption_oracle3from .testing_utils import reproducible_randomness4from .utils import random_bytes5reproducible_randomness6def test_random_bytes():7 assert len(random_bytes(16)) == 168def test_oracle(mocker, reproducible_randomness):9 m_encrypt_ecb = mocker.patch(10 'cryptopals.oracle.encrypt_ecb', side_effect=encrypt_ecb11 )12 m_encrypt_cbc = mocker.patch(13 'cryptopals.oracle.encrypt_cbc', side_effect=encrypt_cbc14 )15 ecb_covered, cbc_covered = False, False16 # ensure we cover both types of encryption17 while not ecb_covered or not cbc_covered:18 ecb_used = detect_cipher(encryption_oracle)19 assert ecb_used == m_encrypt_ecb.called20 assert ecb_used != m_encrypt_cbc.called...
wasp_general_crypto_random_test.py
Source:wasp_general_crypto_random_test.py
...7def test_random_int():8 assert(isinstance(random_int(10), int) is True)9 assert(random_int(1000) != random_int(1000))10 assert(random_int(10) <= 10)11def test_random_bytes():12 pytest.raises(TypeError, random_bytes)13 pytest.raises(TypeError, random_bytes, '1')14 pytest.raises(ValueError, random_bytes, -1)15 assert(isinstance(random_bytes(0), bytes) is True)16 assert(isinstance(random_bytes(3), bytes) is True)17 assert(random_bytes(0) == b'')18 assert(len(random_bytes(10)) == 10)...
test_random.py
Source:test_random.py
...10 rand = random_string()11 assert len(rand) == 612 assert rand not in res13 res.add(rand)14def test_random_bytes():15 res = set()16 for _ in range(100000):17 rand = random_bytes()18 assert len(rand) == 102419 assert rand not in res20 res.add(rand)21@given(length=st.integers(min_value=1, max_value=1024))22def test_random_string_length(length):...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!