Best Python code snippet using selene_python
test_predicate.py
Source:test_predicate.py
...21# SOFTWARE.22from selene.common.predicate import equals_by_contains_to_list23# noinspection PyPep8Naming24class Test__equals_by_contains_to_list:25 def test_same_size(self):26 expected = ['a']27 actual = ['>a<']28 assert equals_by_contains_to_list(expected)(actual)29 assert not equals_by_contains_to_list(actual)(expected)30 def test_expected_list_is_bigger(self):31 expected = ['a', 'b']32 actual = ['>a<']33 assert not equals_by_contains_to_list(expected)(actual)34 def test_expected_list_is_bigger_and_actual_is_empty(self):35 expected = ['a', 'b']36 actual = []37 assert not equals_by_contains_to_list(expected)(actual)38 def test_expected_list_is_smaller(self):39 expected = ['a']40 actual = ['>a<', '>b<']41 assert not equals_by_contains_to_list(expected)(actual)42 def test_expected_list_is_smaller_and_empty(self):43 expected = []44 actual = ['>a<', '>b<']45 assert not equals_by_contains_to_list(expected)(actual)46from selene.common.predicate import equals_to_list47# noinspection PyPep8Naming48class Test__equals_to_list:49 def test_same_size(self):50 expected = ['a', 'b']51 actual = ['a', 'b']52 assert equals_to_list(expected)(actual)53 def test_same_size_and_empty(self):54 expected = []55 actual = []56 assert equals_to_list(expected)(actual)57 def test_expected_list_is_bigger(self):58 expected = ['a', 'b']59 actual = ['a']60 assert not equals_to_list(expected)(actual)61 def test_expected_list_is_bigger_and_actual_is_empty(self):62 expected = ['a']63 actual = []...
test_dataset.py
Source:test_dataset.py
...14 test_training_labels(dataset)15 if name.lower() == "test":16 test_testing_labels(dataset)17def test_training_labels(dataset):18 test_same_size(dataset.images.shape[0], dataset.num_total_images)19 test_same_size(np.count_nonzero(dataset.augmented != "None"), dataset.num_augmented_images)20 test_label(np.unique(dataset.angles), np.array(const.angles_int))21 test_label(np.unique(dataset.distortions), np.array(["low"]))22 test_label(np.unique(dataset.optotypes), np.array(const.optotypes))23 test_label(np.unique(dataset.sizes), np.array(const.TRAINING_IMAGE_SIZES))24def test_testing_labels(dataset):25 test_same_size(dataset.images.shape[0], dataset.num_total_images)26 test_same_size(dataset.num_augmented_images, 0)27 test_label(np.unique(dataset.angles), np.array(const.angles_int))28 test_label(np.unique(dataset.distortions), np.array(["high", "low"]))29 test_label(np.unique(dataset.optotypes), np.array(const.optotypes))30 test_label(np.unique(dataset.sizes), np.array(["S", "M", "L"]))31def test_same_size(len_array, size):32 assert len_array == size, "Length of array {l} neq Size {s}".format(l=len_array, s=size)33def test_label(dataset_attribute, constant_attribute, size=None):34 assert np.all(dataset_attribute == constant_attribute)35 if size:36 assert np.size(dataset_attribute) == size37def test_random_index(dataset, ax, index=None):38 if index is None:39 index = np.random.randint(0, dataset.images.shape[0])40 ax.axis('off')41 ax.imshow(dataset.images[index]/255)42 ax.set_title("Optotype={o}\nAngle={a}\nSize={s}\nDistortion={d}\nisAugmented={ia}".format(o=dataset.optotypes[index],43 a=dataset.angles[index],44 s=dataset.sizes[index],45 d=dataset.distortions[index],...
test_series.py
Source:test_series.py
...16def test_constant():17 s = ud.Series(4, index=['A', 'B', 'C'])18 assert s.loc['A'] == 419 assert s.loc['C'] == 420def test_same_size():21 with pytest.raises(ValueError):22 ud.Series([1, 2, 3], index=['A', 'B', 'C', 'D'])23 with pytest.raises(ValueError):24 ud.Series([1, 2, 3], index=['A', 'B'])25def test_no_index_passed():26 s = ud.Series([5, 4, 3])27 assert s.loc[0] == 528 assert s.loc[1] == 429def test_index():30 s = ud.Series([5, 4, 3], index=['A', 'B', 'C'])31 assert s.index == ['A', 'B', 'C']32def test_repr():33 s = ud.Series([1, 2, 3], index=['A', 'B', 'C'])34 assert repr(s) == """\...
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!!