How to use test_initialization method in avocado

Best Python code snippet using avocado_python

test_exceptions.py

Source:test_exceptions.py Github

copy

Full Screen

...3 InvalidCredentialType, CredentialNotFound, StepsExecutionError4from kallisticore.lib.credential import EnvironmentUserNamePasswordCredential5from kallisticore.models.trial import TrialStepsType6class TestKallistiCoreException(TestCase):7 def test_initialization(self):8 error_message = "sample error message"9 exception = KallistiCoreException(message=error_message)10 self.assertEqual(error_message, exception.message)11 self.assertIsInstance(exception, KallistiCoreException)12class TestFailedAction(TestCase):13 def test_initialization(self):14 error_message = "sample error message"15 exception = FailedAction(message=error_message)16 self.assertEqual(error_message, exception.message)17 self.assertIsInstance(exception, FailedAction)18 self.assertIsInstance(exception, KallistiCoreException)19class TestInvalidCredentialType(TestCase):20 def test_initialization(self):21 credential_type = "INVALID"22 exception = InvalidCredentialType(credential_type)23 self.assertEqual("Invalid credential type: " + credential_type,24 exception.message)25 self.assertIsInstance(exception, InvalidCredentialType)26 self.assertIsInstance(exception, KallistiCoreException)27class TestCredentialNotFound(TestCase):28 def test_initialization(self):29 source = EnvironmentUserNamePasswordCredential.__name__30 exception = CredentialNotFound(source, username_key='user',31 password_key='pass')32 self.assertEqual("Credential not found. Source: " + source +33 ", Details: {'username_key': 'user'"34 ", 'password_key': 'pass'}",35 exception.message)36 self.assertIsInstance(exception, CredentialNotFound)37 self.assertIsInstance(exception, KallistiCoreException)38class TestStepsExecutionError(TestCase):39 def test_initialization(self):40 exception = StepsExecutionError(TrialStepsType.PRE)41 self.assertEqual(TrialStepsType.PRE, exception.step_type)42 self.assertEqual("\"pre_steps\" failed.", exception.message)43 self.assertIsInstance(exception, StepsExecutionError)44 self.assertIsInstance(exception, KallistiCoreException)45 def test_str(self):46 exception = StepsExecutionError(TrialStepsType.PRE)47 exception.__cause__ = RuntimeError("some-error")48 self.assertEqual("[in: pre_steps, reason: some-error]", str(exception))49 def test_is_pre_steps_exception_when_step_type_is_pre_steps(self):50 exception = StepsExecutionError(TrialStepsType.PRE)51 exception.__cause__ = RuntimeError("some-error")52 self.assertTrue(exception.is_pre_steps_exception())53 def test_is_pre_steps_exception_when_step_type_is_post_steps(self):...

Full Screen

Full Screen

LayersTest.py

Source:LayersTest.py Github

copy

Full Screen

1import unittest2from ann.Layers import HiddenLayer, LinearRegressionLayer, LogisticRegressionLayer, InputLayer, LeNetConvPoolLayer3class HiddenLayerTest(unittest.TestCase):4 def test_initialization(self):5 # Given, a total of 6 in and out will result into weights between -1 and 1 according to xavier method6 input_layer = InputLayer([3])7 hidden_layer = HiddenLayer(3)8 # When9 hidden_layer.init_weights(seed=1234, input_layer=input_layer)10 # Then11 params = hidden_layer.params12 weights = params[0].eval()13 for column in weights:14 for value in column:15 self.assertTrue(-1 <= value <= 1)16 bias = params[1].eval()17 for b in bias:18 self.assertEqual(b, 0)19class LinearRegressionLayerTest(unittest.TestCase):20 def test_initialization(self):21 # Given, a total of 6 in and out will result into weights between -1 and 1 according to xavier method22 hidden_layer = HiddenLayer(3)23 linear_regression_layer = LinearRegressionLayer(3)24 # When25 linear_regression_layer.init_weights(seed=1234, input_layer=hidden_layer)26 # Then27 params = linear_regression_layer.params28 weights = params[0].eval()29 for column in weights:30 for value in column:31 self.assertTrue(-1 <= value <= 1)32 bias = params[1].eval()33 for b in bias:34 self.assertEqual(b, 0)35class LogisticRegressionTest(unittest.TestCase):36 def test_initialization(self):37 # Given, a total of 6 in and out will result into weights between -1 and 1 according to xavier method38 hidden_layer = HiddenLayer(3)39 linear_regression_layer = LogisticRegressionLayer(3)40 # When41 linear_regression_layer.init_weights(seed=1234, input_layer=hidden_layer)42 # Then43 params = linear_regression_layer.params44 weights = params[0].eval()45 for column in weights:46 for value in column:47 self.assertTrue(-1 <= value <= 1)48 bias = params[1].eval()49 for b in bias:50 self.assertEqual(b, 0)51class LeNetConvPoolLayerTest(unittest.TestCase):52 def test_initialization(self):53 # Given54 input_layer = InputLayer([4, 4])55 conv_layer = LeNetConvPoolLayer(feature_map=1, filter_shape=(2, 2), pool_size=(1, 2))56 # When57 conv_layer.init_weights(seed=1234, input_layer=input_layer)58 # Then59 params = conv_layer.params60 weights_matrix = params[0].eval()61 for dim in weights_matrix:62 for feature_map in dim:63 for column in feature_map:64 for value in column:65 self.assertTrue(-1 <= value <= 1)66 bias = params[1].eval()...

Full Screen

Full Screen

tests.py

Source:tests.py Github

copy

Full Screen

...5 def setUp(self):6 self.new_project=Projects(name='Insta Clone',image='instagram.jpg',description='A clone of the website for the popular photo app Instagram built using Django Python framework.',link='https://instaclone-django.herokuapp.com/',screen1='home1.png',screen2='profile1.png')7 def test_instace(self):8 self.assertTrue(isinstance(self.new_project,Projects))9 def test_initialization(self):10 self.assertEqual(self.new_project.name,"Insta Clone")11 self.assertEqual(self.new_project.image,"instagram.jpg")12 self.assertEqual(self.new_project.description,"A clone of the website for the popular photo app Instagram built using Django Python framework.")13 self.assertEqual(self.new_project.link,"https://instaclone-django.herokuapp.com/")14 self.assertEqual(self.new_project.screen1,"home1.png")15 self.assertEqual(self.new_project.screen2,"profile1.png")16class TestProfile(TestCase):17 def setUp(self):18 self.new_profile=Profile(profile='Victor',bio='The Jig Is Up!',phone="0719890523")19 def test_instance(self):20 self.assertTrue(isinstance(self.new_profile,Profile))21 def test_initialization(self):22 self.assertEqual(self.new_profile.profile,'Victor')23 self.assertEqual(self.new_profile.bio,'The Jig Is Up!')24 self.assertEqual(self.new_profile.phone,"0719890523")25class TestRating(TestCase):26 def setUp(self):27 self.new_rating=Rates(design=0,usability=0,content=0)28 def test_instance(self):29 self.assertTrue(isinstance(self.new_rating,Rates))30 def test_initialization(self):31 self.assertEqual(self.new_rating.design,0)32 self.assertEqual(self.new_rating.usability,0)33 self.assertEqual(self.new_rating.content,0)34class TestComments(TestCase):35 def setUp(self):36 self.new_comment=Comments(comment="This is a sample comment.",pro_id=0)37 def test_instance(self):38 self.assertTrue(isinstance(self.new_comment,Comments))39 def test_initialization(self):40 self.assertEqual(self.new_comment.comment,"This is a sample comment.")41 self.assertEqual(self.new_comment.pro_id,0)...

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 avocado 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