How to use assert_elements method in SeleniumBase

Best Python code snippet using SeleniumBase

test_memory.py

Source:test_memory.py Github

copy

Full Screen

...4import __init__paths__5from numpy.testing import assert_allclose6from deeprl_hw2.core import ReplayMemory, RingBuffer7def test_ring_buffer():8 def assert_elements(b, ref):9 assert len(b) == len(ref)10 for idx in range(b.maxlen):11 if idx >= len(ref):12 with pytest.raises(KeyError):13 b[idx]14 else:15 assert b[idx] == ref[idx]16 b = RingBuffer(5)17 # Fill buffer.18 assert_elements(b, [])19 b.append(1)20 assert_elements(b, [1])21 b.append(2)22 assert_elements(b, [1, 2])23 b.append(3)24 assert_elements(b, [1, 2, 3])25 b.append(4)26 assert_elements(b, [1, 2, 3, 4])27 b.append(5)28 assert_elements(b, [1, 2, 3, 4, 5])29 # Add couple more items with buffer at limit.30 b.append(6)31 assert_elements(b, [2, 3, 4, 5, 6])32 b.append(7)33 assert_elements(b, [3, 4, 5, 6, 7])34 b.append(8)35 assert_elements(b, [4, 5, 6, 7, 8])36def test_sampling():37 obs_size = (3, 4)38 test = np.random.random(obs_size)39 memory = ReplayMemory(max_size=100, input_shape=obs_size, window_length=2, datatype=test.dtype)40 actions = range(5)41 42 obs0 = np.random.random(obs_size)43 terminal0 = False44 action0 = np.random.choice(actions)45 reward0 = np.random.random()46 47 obs1 = np.random.random(obs_size)48 terminal1 = False49 action1 = np.random.choice(actions)...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run SeleniumBase automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful