How to use test_show method in avocado

Best Python code snippet using avocado_python

Matrix_test.py

Source:Matrix_test.py Github

copy

Full Screen

...4mat1 = Matrix([[1, 2], [3, 2]])5mat2 = Matrix([[3, 4], [4, 10]])6print("Testing Arithmetic Operations:")7result = Matrix.add(mat1,mat2)8assert result.test_show()==Matrix([[4, 6], [7, 12]]).test_show(), "Test Addition failed: output "+ result.test_show() + " expected to be "+Matrix([[4, 6], [5, 12]]).test_show()9print("Test passed")10result = Matrix.subtract(mat2,mat1)11assert result.test_show()==Matrix([[2, 2], [1, 8]]).test_show(), "Test Subtraction failed: output "+ result.test_show() + " expected to be "+Matrix([[2, 2], [1, 8]]).test_show()12print("Test passed")13result = Matrix.scale(mat1,2)14assert result.test_show()==Matrix([[2, 4], [6, 4]]).test_show(), "Test Scaling failed: output "+ result.test_show() + " expected to be "+Matrix([[2, 4], [6, 4]]).test_show()15print("Test passed")16result = Matrix.multiply(mat1,mat2)17assert result.test_show()==Matrix([[11, 24], [17, 32]]).test_show(), "Test Matrix Mult failed: output "+ result.test_show() + " expected to be "+Matrix([[11, 24], [17, 32]]).test_show()18print("Test passed")19result = Matrix.transpose(mat1)20assert result.test_show()==Matrix([[1, 3], [2, 2]]).test_show(), "Test Transpose failed: output "+ result.test_show() + " expected to be "+Matrix([[1, 3], [2, 2]]).test_show()21print("Test passed")22mat1 = Matrix([[1, 2], [3, 2]])23result = Matrix.rref(mat1)24assert result.test_show()==Matrix([[1.0, 0.0], [-0.0, 1.0]]).test_show(), "Test failed: output "+result.test_show()+ " expected to be "+Matrix([[1, 0], [0, 1]]).test_show()25print("Test passed")26print("rref checks:")27mat1 = Matrix([[5, 4, 6, 3, 10], [5, 5, 1, 9, 9], [3, 3, 4, 10, 7]])28result = Matrix.rref(mat1)29assert result.test_show()==Matrix([[1.0, 0.0, 0.0, -11.235294117647065, 0.3529411764705874], [0.0, 1.0, 0.0, 12.764705882352946, 1.3529411764705888], [0.0, 0.0, 1.0, 1.3529411764705892, 0.47058823529411775]]).test_show(), "Test failed: output "+result.test_show()+ " expected to be "+Matrix([[1, 0, 0, -11.235294117647065, 0.3529411764705874], [0, 1, 0, 12.764705882352946,301.3529411764705888], [0.0, 0.0, 1.0, 1.3529411764705892, 0.47058823529411775]]).test_show()31print("Test passed")32mat1 = Matrix([[10, 10, 6], [9, 4, 7], [1, 10, 8], [1, 3, 5], [8, 2, 3]])33result = Matrix.rref(mat1)34assert result.test_show()==Matrix([[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]]).test_show(), "Test failed: output "+result.test_show()+ " expected to be "+Matrix([[1, 0, 0], [0, 1, 0], [0.0, 0.0, 1.0], [0, 0, 0], [0, 0, 0]]).test_show()35print("Test passed")36mat1 = Matrix([[1, 0, 0], [0, 1, 0], [0.0, 0.0, 1.0], [0, 0, 0], [0, 0, 0]])37result = Matrix.rref(mat1)38assert result.test_show()==Matrix([[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]]).test_show(), "Test failed: output "+result.test_show()+ " expected to be "+Matrix([[1, 0, 0], [0, 1, 0], [0.0, 0.0, 1.0], [0, 0, 0], [0, 0, 0]]).test_show()39print("Test passed")40mat1 = Matrix([[9, 1, 6, 6, 10], [1, 9, 9, 1, 7], [41 2, 4, 3, 9, 5], [1, 7, 3, 5, 0], [8, 3, 10, 7, 7]])42result = Matrix.rref(mat1)43assert result.test_show()==Matrix([[1.0, 0.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 0.0, 1.0, 0.0], [-0.0, -0.0, -0.0, -0.0, 1.0]]).test_show(), "Test failed: output "+result.test_show()+ " expected to be "+Matrix([[1.0, 0.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 0.0, 1.0, 0.0], [-0.0, -0.0, -0.0, -0.0, 1.0]]).test_show()44print("Test passed")45mat1 = Matrix([[7, 10, 2, 9, 10], [4, 3, 6, 2, 5], [2, 9, 5, 9, 4]])46result = Matrix.rref(mat1)47assert result.test_show()==Matrix([[1.0, 0.0, 0.0, -0.2423208191126282, 1.1399317406143346], [0.0, 1.0, 0.0, 1.0784982935153584,0.2081911262798635], [0.0, 0.0, 1.0, -0.044368600682593795, -0.030716723549488064]]).test_show(), "Test failed: output "+result.test_show()+ " expected to be "+Matrix([[1.0, 0.0, 0.0, -0.24232081911262804, 1.1399317406143346], [0.0, 1.0, 0.0, 1.0784982935153584,0.2081911262798635], [0.0, 0.0, 1.0, -0.044368600682593795, -0.030716723549488064]]).test_show()48print("Test passed")49print("det checks:")50mat1 = Matrix([[1, 2, 3], [1, 2, 4], [0, 0, 0]])51result = Matrix.recursive_det(mat1)52assert result == 0, "Test failed: output "+str(result)+ " expected to be 0"53print("Test passed")54#invertible Matrix55mat1 = Matrix([[9, 3, 8], [5, 1, 6], [10, 0, 1]])56result = Matrix.recursive_det(mat1)57assert result == 94, "Test failed: output "+str(result)+ " expected to be 94"58print("Test passed")59mat1 = Matrix([[9, 3, 8], [5, 1, 6], [10, 0, 1]])60result = Matrix.inverse_by_minors(mat1)61assert result == [[0.010638297872340413, -0.03191489361702121, 0.10638297872340424], [0.5851063829787235, -0.7553191489361706, -0.14893617021276595], [-0.1063829787234043, 0.3191489361702128, -0.06382978723404255]], "Test failed: output "+result.test_show()+ " expected to be "+Matrix([[0.010638297872340413, -0.03191489361702121, 0.10638297872340424], [0.5851063829787235, -0.7553191489361706, -0.14893617021276595], [-0.1063829787234043,0.3191489361702128, -0.06382978723404255]]).test_show()62print("Test passed")63# assert result.test_show() == , "Test failed: output "+result.test_show()+ " expected to be "+{expected}...

Full Screen

Full Screen

test_show.py

Source:test_show.py Github

copy

Full Screen

1#!/usr/bin/env python2#3# Licensed under the Apache License, Version 2.0 (the "License"); you may4# not use this file except in compliance with the License. You may obtain5# a copy of the License at6#7# http://www.apache.org/licenses/LICENSE-2.08#9# Unless required by applicable law or agreed to in writing, software10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the12# License for the specific language governing permissions and limitations13# under the License.14import weakref15from cliff import show16from cliff.tests import base17import mock18class FauxFormatter(object):19 def __init__(self):20 self.args = []21 self.obj = weakref.proxy(self)22 def emit_one(self, columns, data, stdout, args):23 self.args.append((columns, data))24class ExerciseShowOne(show.ShowOne):25 def _load_formatter_plugins(self):26 return {27 'test': FauxFormatter(),28 }29 def take_action(self, parsed_args):30 return (31 parsed_args.columns,32 [('a', 'A'), ('b', 'B')],33 )34class TestShow(base.TestBase):35 def test_formatter_args(self):36 app = mock.Mock()37 test_show = ExerciseShowOne(app, [])38 parsed_args = mock.Mock()39 parsed_args.columns = ('Col1', 'Col2')40 parsed_args.formatter = 'test'41 test_show.run(parsed_args)42 f = test_show._formatter_plugins['test']43 self.assertEqual(1, len(f.args))44 args = f.args[0]45 self.assertEqual(list(parsed_args.columns), args[0])46 data = list(args[1])47 self.assertEqual([('a', 'A'), ('b', 'B')], data)48 def test_dict2columns(self):49 app = mock.Mock()50 test_show = ExerciseShowOne(app, [])51 d = {'a': 'A', 'b': 'B', 'c': 'C'}52 expected = [('a', 'b', 'c'), ('A', 'B', 'C')]53 actual = list(test_show.dict2columns(d))54 self.assertEqual(expected, actual)55 def test_no_exist_column(self):56 test_show = ExerciseShowOne(mock.Mock(), [])57 parsed_args = mock.Mock()58 parsed_args.columns = ('no_exist_column',)59 parsed_args.formatter = 'test'60 with mock.patch.object(test_show, 'take_action') as mock_take_action:61 mock_take_action.return_value = (('Col1', 'Col2', 'Col3'), [])62 self.assertRaises(63 ValueError,64 test_show.run,65 parsed_args,...

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