Best Python code snippet using autotest_python
step_solution_data_test.py
Source:step_solution_data_test.py
1# coding=utf-82import numpy3from pypint.solutions.data_storage.step_solution_data import StepSolutionData4from pypint.solvers.diagnosis import Error, Residual5from tests import NumpyAwareTestCase6class StepSolutionDataTest(NumpyAwareTestCase):7 def setUp(self):8 self._default = StepSolutionData()9 self._value = numpy.array([1.0, 2.0], dtype=numpy.float)10 self._error = Error(value=numpy.array([1.0], dtype=numpy.float))11 self._residual = Residual(value=numpy.array([0.01], dtype=numpy.float))12 def test_provides_value(self):13 self.assertIsNone(self._default.value, "Default value is 'None'.")14 self._default.value = self._value15 self.assertNumpyArrayEqual(self._default.value, self._value)16 self.assertEqual(self._default.dim, self._value.shape)17 self.assertEqual(self._default.numeric_type, self._value.dtype)18 self._default.finalize()19 with self.assertRaises(AttributeError):20 self._default.value = self._value21 _test = StepSolutionData(value=self._value)22 self.assertEqual(_test.dim, self._value.shape)23 self.assertEqual(_test.numeric_type, self._value.dtype)24 self.assertNumpyArrayEqual(_test.value, self._value)25 with self.assertRaises(ValueError):26 StepSolutionData(value="not numpy.ndarray")27 def test_provides_time_point(self):28 self.assertIsNone(self._default.time_point)29 self._default.time_point = 1.030 self.assertEqual(self._default.time_point, 1.0)31 self._default.finalize()32 with self.assertRaises(AttributeError):33 self._default.time_point = 0.034 _test = StepSolutionData(time_point=0.0)35 self.assertEqual(_test.time_point, 0.0)36 with self.assertRaises(ValueError):37 StepSolutionData(time_point="not float")38 def test_provides_error(self):39 self.assertIsNone(self._default.error)40 self._default.error = self._error41 self.assertEqual(self._default.error, self._error)42 self._default.finalize()43 with self.assertRaises(AttributeError):44 self._default.error = self._error45 _test = StepSolutionData(error=self._error)46 self.assertEqual(_test.error, self._error)47 with self.assertRaises(ValueError):48 StepSolutionData(error="not numpy.ndarray")49 def test_provides_residual(self):50 self.assertIsNone(self._default.residual)51 self._default.residual = self._residual52 self.assertEqual(self._default.residual, self._residual)53 self._default.finalize()54 with self.assertRaises(AttributeError):55 self._default.residual = self._residual56 _test = StepSolutionData(residual=self._residual)57 self.assertEqual(_test.residual, self._residual)58 with self.assertRaises(ValueError):59 StepSolutionData(residual="not numpy.ndarray")60 def test_is_comparable(self):61 _test1 = StepSolutionData(value=self._value, time_point=0.0, error=self._error, residual=self._residual)62 _test2 = StepSolutionData(value=self._value, time_point=0.0, error=self._error, residual=self._residual)63 self.assertTrue(_test1 == _test2)64 self.assertTrue(_test1.__eq__(_test2))65 self.assertFalse(_test1 != _test2)66 self.assertFalse(_test1.__ne__(_test2))67 _test2.time_point = 1.068 self.assertTrue(_test1 < _test2)69 self.assertTrue(_test1.__lt__(_test2))70 self.assertTrue(_test1 <= _test2)71 self.assertTrue(_test1.__le__(_test2))72 self.assertFalse(_test1 > _test2)73 self.assertFalse(_test1.__gt__(_test2))74 self.assertFalse(_test1 >= _test2)75 self.assertFalse(_test1.__ge__(_test2))76if __name__ == '__main__':77 import unittest...
test_testexecutionresult.py
Source:test_testexecutionresult.py
1import unittest2from robotide.controller.testexecutionresults import TestExecutionResults3class TestExecutionResultTestCase(unittest.TestCase):4 def setUp(self):5 self._results = TestExecutionResults()6 self._test = object()7 self._test2 = object()8 def test_running_test(self):9 self._results.set_running(self._test)10 self._expect_running(self._test)11 self._results.set_passed(self._test)12 self._expect_passed(self._test)13 def _expect_passed(self, test):14 self.assertFalse(self._results.is_running(test))15 self.assertTrue(self._results.has_passed(test))16 self.assertFalse(self._results.has_failed(test))17 def _expect_running(self, test):18 self.assertTrue(self._results.is_running(test))19 self.assertFalse(self._results.has_passed(test))20 self.assertFalse(self._results.has_failed(test))21 def test_running_test_that_fails(self):22 self._results.set_running(self._test)23 self._expect_running(self._test)24 self._results.set_failed(self._test)25 self._expect_failed(self._test)26 def _expect_failed(self, test):27 self.assertFalse(self._results.is_running(test))28 self.assertFalse(self._results.has_passed(test))29 self.assertTrue(self._results.has_failed(test))30 def test_running_two_tests(self):31 self._results.set_running(self._test)32 self._expect_running(self._test)33 self._expect_no_result(self._test2)34 self._results.set_failed(self._test)35 self._expect_failed(self._test)36 self._results.set_running(self._test2)37 self._expect_running(self._test2)38 self._expect_failed(self._test)39 self._results.set_passed(self._test2)40 self._expect_passed(self._test2)41 self._expect_failed(self._test)42 def test_clearing_results(self):43 self._results.set_running(self._test)44 self._results.set_passed(self._test)45 self._results.set_running(self._test2)46 self._results.set_passed(self._test2)47 self._results.clear()48 self._expect_no_result(self._test)49 self._expect_no_result(self._test2)50 def _expect_no_result(self, test):51 self.assertFalse(self._results.is_running(test))52 self.assertFalse(self._results.has_passed(test))53 self.assertFalse(self._results.has_failed(test))54if __name__ == '__main__':...
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!!