How to use failure method in Playwright Internal

Best JavaScript code snippet using playwright-internal

test_case.py

Source:test_case.py Github

copy

Full Screen

1import difflib2import pprint3import pickle4import re5import sys67from copy import deepcopy8from test import test_support910import unittest1112from unittest.test.support import (13 TestEquality, TestHashing, LoggingResult, ResultWithNoStartTestRunStopTestRun14)151617class Test(object):18 "Keep these TestCase classes out of the main namespace"1920 class Foo(unittest.TestCase):21 def runTest(self): pass22 def test1(self): pass2324 class Bar(Foo):25 def test2(self): pass2627 class LoggingTestCase(unittest.TestCase):28 """A test case which logs its calls."""2930 def __init__(self, events):31 super(Test.LoggingTestCase, self).__init__('test')32 self.events = events3334 def setUp(self):35 self.events.append('setUp')3637 def test(self):38 self.events.append('test')3940 def tearDown(self):41 self.events.append('tearDown')424344class Test_TestCase(unittest.TestCase, TestEquality, TestHashing):4546 ### Set up attributes used by inherited tests47 ################################################################4849 # Used by TestHashing.test_hash and TestEquality.test_eq50 eq_pairs = [(Test.Foo('test1'), Test.Foo('test1'))]5152 # Used by TestEquality.test_ne53 ne_pairs = [(Test.Foo('test1'), Test.Foo('runTest'))54 ,(Test.Foo('test1'), Test.Bar('test1'))55 ,(Test.Foo('test1'), Test.Bar('test2'))]5657 ################################################################58 ### /Set up attributes used by inherited tests596061 # "class TestCase([methodName])"62 # ...63 # "Each instance of TestCase will run a single test method: the64 # method named methodName."65 # ...66 # "methodName defaults to "runTest"."67 #68 # Make sure it really is optional, and that it defaults to the proper69 # thing.70 def test_init__no_test_name(self):71 class Test(unittest.TestCase):72 def runTest(self): raise TypeError()73 def test(self): pass7475 self.assertEqual(Test().id()[-13:], '.Test.runTest')7677 # "class TestCase([methodName])"78 # ...79 # "Each instance of TestCase will run a single test method: the80 # method named methodName."81 def test_init__test_name__valid(self):82 class Test(unittest.TestCase):83 def runTest(self): raise TypeError()84 def test(self): pass8586 self.assertEqual(Test('test').id()[-10:], '.Test.test')8788 # "class TestCase([methodName])"89 # ...90 # "Each instance of TestCase will run a single test method: the91 # method named methodName."92 def test_init__test_name__invalid(self):93 class Test(unittest.TestCase):94 def runTest(self): raise TypeError()95 def test(self): pass9697 try:98 Test('testfoo')99 except ValueError:100 pass101 else:102 self.fail("Failed to raise ValueError")103104 # "Return the number of tests represented by the this test object. For105 # TestCase instances, this will always be 1"106 def test_countTestCases(self):107 class Foo(unittest.TestCase):108 def test(self): pass109110 self.assertEqual(Foo('test').countTestCases(), 1)111112 # "Return the default type of test result object to be used to run this113 # test. For TestCase instances, this will always be114 # unittest.TestResult; subclasses of TestCase should115 # override this as necessary."116 def test_defaultTestResult(self):117 class Foo(unittest.TestCase):118 def runTest(self):119 pass120121 result = Foo().defaultTestResult()122 self.assertEqual(type(result), unittest.TestResult)123124 # "When a setUp() method is defined, the test runner will run that method125 # prior to each test. Likewise, if a tearDown() method is defined, the126 # test runner will invoke that method after each test. In the example,127 # setUp() was used to create a fresh sequence for each test."128 #129 # Make sure the proper call order is maintained, even if setUp() raises130 # an exception.131 def test_run_call_order__error_in_setUp(self):132 events = []133 result = LoggingResult(events)134135 class Foo(Test.LoggingTestCase):136 def setUp(self):137 super(Foo, self).setUp()138 raise RuntimeError('raised by Foo.setUp')139140 Foo(events).run(result)141 expected = ['startTest', 'setUp', 'addError', 'stopTest']142 self.assertEqual(events, expected)143144 # "With a temporary result stopTestRun is called when setUp errors.145 def test_run_call_order__error_in_setUp_default_result(self):146 events = []147148 class Foo(Test.LoggingTestCase):149 def defaultTestResult(self):150 return LoggingResult(self.events)151152 def setUp(self):153 super(Foo, self).setUp()154 raise RuntimeError('raised by Foo.setUp')155156 Foo(events).run()157 expected = ['startTestRun', 'startTest', 'setUp', 'addError',158 'stopTest', 'stopTestRun']159 self.assertEqual(events, expected)160161 # "When a setUp() method is defined, the test runner will run that method162 # prior to each test. Likewise, if a tearDown() method is defined, the163 # test runner will invoke that method after each test. In the example,164 # setUp() was used to create a fresh sequence for each test."165 #166 # Make sure the proper call order is maintained, even if the test raises167 # an error (as opposed to a failure).168 def test_run_call_order__error_in_test(self):169 events = []170 result = LoggingResult(events)171172 class Foo(Test.LoggingTestCase):173 def test(self):174 super(Foo, self).test()175 raise RuntimeError('raised by Foo.test')176177 expected = ['startTest', 'setUp', 'test', 'addError', 'tearDown',178 'stopTest']179 Foo(events).run(result)180 self.assertEqual(events, expected)181182 # "With a default result, an error in the test still results in stopTestRun183 # being called."184 def test_run_call_order__error_in_test_default_result(self):185 events = []186187 class Foo(Test.LoggingTestCase):188 def defaultTestResult(self):189 return LoggingResult(self.events)190191 def test(self):192 super(Foo, self).test()193 raise RuntimeError('raised by Foo.test')194195 expected = ['startTestRun', 'startTest', 'setUp', 'test', 'addError',196 'tearDown', 'stopTest', 'stopTestRun']197 Foo(events).run()198 self.assertEqual(events, expected)199200 # "When a setUp() method is defined, the test runner will run that method201 # prior to each test. Likewise, if a tearDown() method is defined, the202 # test runner will invoke that method after each test. In the example,203 # setUp() was used to create a fresh sequence for each test."204 #205 # Make sure the proper call order is maintained, even if the test signals206 # a failure (as opposed to an error).207 def test_run_call_order__failure_in_test(self):208 events = []209 result = LoggingResult(events)210211 class Foo(Test.LoggingTestCase):212 def test(self):213 super(Foo, self).test()214 self.fail('raised by Foo.test')215216 expected = ['startTest', 'setUp', 'test', 'addFailure', 'tearDown',217 'stopTest']218 Foo(events).run(result)219 self.assertEqual(events, expected)220221 # "When a test fails with a default result stopTestRun is still called."222 def test_run_call_order__failure_in_test_default_result(self):223224 class Foo(Test.LoggingTestCase):225 def defaultTestResult(self):226 return LoggingResult(self.events)227 def test(self):228 super(Foo, self).test()229 self.fail('raised by Foo.test')230231 expected = ['startTestRun', 'startTest', 'setUp', 'test', 'addFailure',232 'tearDown', 'stopTest', 'stopTestRun']233 events = []234 Foo(events).run()235 self.assertEqual(events, expected)236237 # "When a setUp() method is defined, the test runner will run that method238 # prior to each test. Likewise, if a tearDown() method is defined, the239 # test runner will invoke that method after each test. In the example,240 # setUp() was used to create a fresh sequence for each test."241 #242 # Make sure the proper call order is maintained, even if tearDown() raises243 # an exception.244 def test_run_call_order__error_in_tearDown(self):245 events = []246 result = LoggingResult(events)247248 class Foo(Test.LoggingTestCase):249 def tearDown(self):250 super(Foo, self).tearDown()251 raise RuntimeError('raised by Foo.tearDown')252253 Foo(events).run(result)254 expected = ['startTest', 'setUp', 'test', 'tearDown', 'addError',255 'stopTest']256 self.assertEqual(events, expected)257258 # "When tearDown errors with a default result stopTestRun is still called."259 def test_run_call_order__error_in_tearDown_default_result(self):260261 class Foo(Test.LoggingTestCase):262 def defaultTestResult(self):263 return LoggingResult(self.events)264 def tearDown(self):265 super(Foo, self).tearDown()266 raise RuntimeError('raised by Foo.tearDown')267268 events = []269 Foo(events).run()270 expected = ['startTestRun', 'startTest', 'setUp', 'test', 'tearDown',271 'addError', 'stopTest', 'stopTestRun']272 self.assertEqual(events, expected)273274 # "TestCase.run() still works when the defaultTestResult is a TestResult275 # that does not support startTestRun and stopTestRun.276 def test_run_call_order_default_result(self):277278 class Foo(unittest.TestCase):279 def defaultTestResult(self):280 return ResultWithNoStartTestRunStopTestRun()281 def test(self):282 pass283284 Foo('test').run()285286 # "This class attribute gives the exception raised by the test() method.287 # If a test framework needs to use a specialized exception, possibly to288 # carry additional information, it must subclass this exception in289 # order to ``play fair'' with the framework. The initial value of this290 # attribute is AssertionError"291 def test_failureException__default(self):292 class Foo(unittest.TestCase):293 def test(self):294 pass295296 self.assertIs(Foo('test').failureException, AssertionError)297298 # "This class attribute gives the exception raised by the test() method.299 # If a test framework needs to use a specialized exception, possibly to300 # carry additional information, it must subclass this exception in301 # order to ``play fair'' with the framework."302 #303 # Make sure TestCase.run() respects the designated failureException304 def test_failureException__subclassing__explicit_raise(self):305 events = []306 result = LoggingResult(events)307308 class Foo(unittest.TestCase):309 def test(self):310 raise RuntimeError()311312 failureException = RuntimeError313314 self.assertIs(Foo('test').failureException, RuntimeError)315316317 Foo('test').run(result)318 expected = ['startTest', 'addFailure', 'stopTest']319 self.assertEqual(events, expected)320321 # "This class attribute gives the exception raised by the test() method.322 # If a test framework needs to use a specialized exception, possibly to323 # carry additional information, it must subclass this exception in324 # order to ``play fair'' with the framework."325 #326 # Make sure TestCase.run() respects the designated failureException327 def test_failureException__subclassing__implicit_raise(self):328 events = []329 result = LoggingResult(events)330331 class Foo(unittest.TestCase):332 def test(self):333 self.fail("foo")334335 failureException = RuntimeError336337 self.assertIs(Foo('test').failureException, RuntimeError)338339340 Foo('test').run(result)341 expected = ['startTest', 'addFailure', 'stopTest']342 self.assertEqual(events, expected)343344 # "The default implementation does nothing."345 def test_setUp(self):346 class Foo(unittest.TestCase):347 def runTest(self):348 pass349350 # ... and nothing should happen351 Foo().setUp()352353 # "The default implementation does nothing."354 def test_tearDown(self):355 class Foo(unittest.TestCase):356 def runTest(self):357 pass358359 # ... and nothing should happen360 Foo().tearDown()361362 # "Return a string identifying the specific test case."363 #364 # Because of the vague nature of the docs, I'm not going to lock this365 # test down too much. Really all that can be asserted is that the id()366 # will be a string (either 8-byte or unicode -- again, because the docs367 # just say "string")368 def test_id(self):369 class Foo(unittest.TestCase):370 def runTest(self):371 pass372373 self.assertIsInstance(Foo().id(), basestring)374375 # "If result is omitted or None, a temporary result object is created376 # and used, but is not made available to the caller. As TestCase owns the377 # temporary result startTestRun and stopTestRun are called.378379 def test_run__uses_defaultTestResult(self):380 events = []381382 class Foo(unittest.TestCase):383 def test(self):384 events.append('test')385386 def defaultTestResult(self):387 return LoggingResult(events)388389 # Make run() find a result object on its own390 Foo('test').run()391392 expected = ['startTestRun', 'startTest', 'test', 'addSuccess',393 'stopTest', 'stopTestRun']394 self.assertEqual(events, expected)395396 def testShortDescriptionWithoutDocstring(self):397 self.assertIsNone(self.shortDescription())398399 @unittest.skipIf(sys.flags.optimize >= 2,400 "Docstrings are omitted with -O2 and above")401 def testShortDescriptionWithOneLineDocstring(self):402 """Tests shortDescription() for a method with a docstring."""403 self.assertEqual(404 self.shortDescription(),405 'Tests shortDescription() for a method with a docstring.')406407 @unittest.skipIf(sys.flags.optimize >= 2,408 "Docstrings are omitted with -O2 and above")409 def testShortDescriptionWithMultiLineDocstring(self):410 """Tests shortDescription() for a method with a longer docstring.411412 This method ensures that only the first line of a docstring is413 returned used in the short description, no matter how long the414 whole thing is.415 """416 self.assertEqual(417 self.shortDescription(),418 'Tests shortDescription() for a method with a longer '419 'docstring.')420421 def testAddTypeEqualityFunc(self):422 class SadSnake(object):423 """Dummy class for test_addTypeEqualityFunc."""424 s1, s2 = SadSnake(), SadSnake()425 self.assertNotEqual(s1, s2)426 def AllSnakesCreatedEqual(a, b, msg=None):427 return type(a) is type(b) is SadSnake428 self.addTypeEqualityFunc(SadSnake, AllSnakesCreatedEqual)429 self.assertEqual(s1, s2)430 # No this doesn't clean up and remove the SadSnake equality func431 # from this TestCase instance but since its a local nothing else432 # will ever notice that.433434 def testAssertIs(self):435 thing = object()436 self.assertIs(thing, thing)437 self.assertRaises(self.failureException, self.assertIs, thing, object())438439 def testAssertIsNot(self):440 thing = object()441 self.assertIsNot(thing, object())442 self.assertRaises(self.failureException, self.assertIsNot, thing, thing)443444 def testAssertIsInstance(self):445 thing = []446 self.assertIsInstance(thing, list)447 self.assertRaises(self.failureException, self.assertIsInstance,448 thing, dict)449450 def testAssertNotIsInstance(self):451 thing = []452 self.assertNotIsInstance(thing, dict)453 self.assertRaises(self.failureException, self.assertNotIsInstance,454 thing, list)455456 def testAssertIn(self):457 animals = {'monkey': 'banana', 'cow': 'grass', 'seal': 'fish'}458459 self.assertIn('a', 'abc')460 self.assertIn(2, [1, 2, 3])461 self.assertIn('monkey', animals)462463 self.assertNotIn('d', 'abc')464 self.assertNotIn(0, [1, 2, 3])465 self.assertNotIn('otter', animals)466467 self.assertRaises(self.failureException, self.assertIn, 'x', 'abc')468 self.assertRaises(self.failureException, self.assertIn, 4, [1, 2, 3])469 self.assertRaises(self.failureException, self.assertIn, 'elephant',470 animals)471472 self.assertRaises(self.failureException, self.assertNotIn, 'c', 'abc')473 self.assertRaises(self.failureException, self.assertNotIn, 1, [1, 2, 3])474 self.assertRaises(self.failureException, self.assertNotIn, 'cow',475 animals)476477 def testAssertDictContainsSubset(self):478 self.assertDictContainsSubset({}, {})479 self.assertDictContainsSubset({}, {'a': 1})480 self.assertDictContainsSubset({'a': 1}, {'a': 1})481 self.assertDictContainsSubset({'a': 1}, {'a': 1, 'b': 2})482 self.assertDictContainsSubset({'a': 1, 'b': 2}, {'a': 1, 'b': 2})483484 with self.assertRaises(self.failureException):485 self.assertDictContainsSubset({1: "one"}, {})486487 with self.assertRaises(self.failureException):488 self.assertDictContainsSubset({'a': 2}, {'a': 1})489490 with self.assertRaises(self.failureException):491 self.assertDictContainsSubset({'c': 1}, {'a': 1})492493 with self.assertRaises(self.failureException):494 self.assertDictContainsSubset({'a': 1, 'c': 1}, {'a': 1})495496 with self.assertRaises(self.failureException):497 self.assertDictContainsSubset({'a': 1, 'c': 1}, {'a': 1})498499 with test_support.check_warnings(("", UnicodeWarning)):500 one = ''.join(chr(i) for i in range(255))501 # this used to cause a UnicodeDecodeError constructing the failure msg502 with self.assertRaises(self.failureException):503 self.assertDictContainsSubset({'foo': one}, {'foo': u'\uFFFD'})504505 def testAssertEqual(self):506 equal_pairs = [507 ((), ()),508 ({}, {}),509 ([], []),510 (set(), set()),511 (frozenset(), frozenset())]512 for a, b in equal_pairs:513 # This mess of try excepts is to test the assertEqual behavior514 # itself.515 try:516 self.assertEqual(a, b)517 except self.failureException:518 self.fail('assertEqual(%r, %r) failed' % (a, b))519 try:520 self.assertEqual(a, b, msg='foo')521 except self.failureException:522 self.fail('assertEqual(%r, %r) with msg= failed' % (a, b))523 try:524 self.assertEqual(a, b, 'foo')525 except self.failureException:526 self.fail('assertEqual(%r, %r) with third parameter failed' %527 (a, b))528529 unequal_pairs = [530 ((), []),531 ({}, set()),532 (set([4,1]), frozenset([4,2])),533 (frozenset([4,5]), set([2,3])),534 (set([3,4]), set([5,4]))]535 for a, b in unequal_pairs:536 self.assertRaises(self.failureException, self.assertEqual, a, b)537 self.assertRaises(self.failureException, self.assertEqual, a, b,538 'foo')539 self.assertRaises(self.failureException, self.assertEqual, a, b,540 msg='foo')541542 def testEquality(self):543 self.assertListEqual([], [])544 self.assertTupleEqual((), ())545 self.assertSequenceEqual([], ())546547 a = [0, 'a', []]548 b = []549 self.assertRaises(unittest.TestCase.failureException,550 self.assertListEqual, a, b)551 self.assertRaises(unittest.TestCase.failureException,552 self.assertListEqual, tuple(a), tuple(b))553 self.assertRaises(unittest.TestCase.failureException,554 self.assertSequenceEqual, a, tuple(b))555556 b.extend(a)557 self.assertListEqual(a, b)558 self.assertTupleEqual(tuple(a), tuple(b))559 self.assertSequenceEqual(a, tuple(b))560 self.assertSequenceEqual(tuple(a), b)561562 self.assertRaises(self.failureException, self.assertListEqual,563 a, tuple(b))564 self.assertRaises(self.failureException, self.assertTupleEqual,565 tuple(a), b)566 self.assertRaises(self.failureException, self.assertListEqual, None, b)567 self.assertRaises(self.failureException, self.assertTupleEqual, None,568 tuple(b))569 self.assertRaises(self.failureException, self.assertSequenceEqual,570 None, tuple(b))571 self.assertRaises(self.failureException, self.assertListEqual, 1, 1)572 self.assertRaises(self.failureException, self.assertTupleEqual, 1, 1)573 self.assertRaises(self.failureException, self.assertSequenceEqual,574 1, 1)575576 self.assertDictEqual({}, {})577578 c = { 'x': 1 }579 d = {}580 self.assertRaises(unittest.TestCase.failureException,581 self.assertDictEqual, c, d)582583 d.update(c)584 self.assertDictEqual(c, d)585586 d['x'] = 0587 self.assertRaises(unittest.TestCase.failureException,588 self.assertDictEqual, c, d, 'These are unequal')589590 self.assertRaises(self.failureException, self.assertDictEqual, None, d)591 self.assertRaises(self.failureException, self.assertDictEqual, [], d)592 self.assertRaises(self.failureException, self.assertDictEqual, 1, 1)593594 def testAssertSequenceEqualMaxDiff(self):595 self.assertEqual(self.maxDiff, 80*8)596 seq1 = 'a' + 'x' * 80**2597 seq2 = 'b' + 'x' * 80**2598 diff = '\n'.join(difflib.ndiff(pprint.pformat(seq1).splitlines(),599 pprint.pformat(seq2).splitlines()))600 # the +1 is the leading \n added by assertSequenceEqual601 omitted = unittest.case.DIFF_OMITTED % (len(diff) + 1,)602603 self.maxDiff = len(diff)//2604 try:605 self.assertSequenceEqual(seq1, seq2)606 except self.failureException as e:607 msg = e.args[0]608 else:609 self.fail('assertSequenceEqual did not fail.')610 self.assertLess(len(msg), len(diff))611 self.assertIn(omitted, msg)612613 self.maxDiff = len(diff) * 2614 try:615 self.assertSequenceEqual(seq1, seq2)616 except self.failureException as e:617 msg = e.args[0]618 else:619 self.fail('assertSequenceEqual did not fail.')620 self.assertGreater(len(msg), len(diff))621 self.assertNotIn(omitted, msg)622623 self.maxDiff = None624 try:625 self.assertSequenceEqual(seq1, seq2)626 except self.failureException as e:627 msg = e.args[0]628 else:629 self.fail('assertSequenceEqual did not fail.')630 self.assertGreater(len(msg), len(diff))631 self.assertNotIn(omitted, msg)632633 def testTruncateMessage(self):634 self.maxDiff = 1635 message = self._truncateMessage('foo', 'bar')636 omitted = unittest.case.DIFF_OMITTED % len('bar')637 self.assertEqual(message, 'foo' + omitted)638639 self.maxDiff = None640 message = self._truncateMessage('foo', 'bar')641 self.assertEqual(message, 'foobar')642643 self.maxDiff = 4644 message = self._truncateMessage('foo', 'bar')645 self.assertEqual(message, 'foobar')646647 def testAssertDictEqualTruncates(self):648 test = unittest.TestCase('assertEqual')649 def truncate(msg, diff):650 return 'foo'651 test._truncateMessage = truncate652 try:653 test.assertDictEqual({}, {1: 0})654 except self.failureException as e:655 self.assertEqual(str(e), 'foo')656 else:657 self.fail('assertDictEqual did not fail')658659 def testAssertMultiLineEqualTruncates(self):660 test = unittest.TestCase('assertEqual')661 def truncate(msg, diff):662 return 'foo'663 test._truncateMessage = truncate664 try:665 test.assertMultiLineEqual('foo', 'bar')666 except self.failureException as e:667 self.assertEqual(str(e), 'foo')668 else:669 self.fail('assertMultiLineEqual did not fail')670671 def testAssertEqual_diffThreshold(self):672 # check threshold value673 self.assertEqual(self._diffThreshold, 2**16)674 # disable madDiff to get diff markers675 self.maxDiff = None676677 # set a lower threshold value and add a cleanup to restore it678 old_threshold = self._diffThreshold679 self._diffThreshold = 2**8680 self.addCleanup(lambda: setattr(self, '_diffThreshold', old_threshold))681682 # under the threshold: diff marker (^) in error message683 s = u'x' * (2**7)684 with self.assertRaises(self.failureException) as cm:685 self.assertEqual(s + 'a', s + 'b')686 self.assertIn('^', str(cm.exception))687 self.assertEqual(s + 'a', s + 'a')688689 # over the threshold: diff not used and marker (^) not in error message690 s = u'x' * (2**9)691 # if the path that uses difflib is taken, _truncateMessage will be692 # called -- replace it with explodingTruncation to verify that this693 # doesn't happen694 def explodingTruncation(message, diff):695 raise SystemError('this should not be raised')696 old_truncate = self._truncateMessage697 self._truncateMessage = explodingTruncation698 self.addCleanup(lambda: setattr(self, '_truncateMessage', old_truncate))699700 s1, s2 = s + 'a', s + 'b'701 with self.assertRaises(self.failureException) as cm:702 self.assertEqual(s1, s2)703 self.assertNotIn('^', str(cm.exception))704 self.assertEqual(str(cm.exception), '%r != %r' % (s1, s2))705 self.assertEqual(s + 'a', s + 'a')706707 def testAssertItemsEqual(self):708 a = object()709 self.assertItemsEqual([1, 2, 3], [3, 2, 1])710 self.assertItemsEqual(['foo', 'bar', 'baz'], ['bar', 'baz', 'foo'])711 self.assertItemsEqual([a, a, 2, 2, 3], (a, 2, 3, a, 2))712 self.assertItemsEqual([1, "2", "a", "a"], ["a", "2", True, "a"])713 self.assertRaises(self.failureException, self.assertItemsEqual,714 [1, 2] + [3] * 100, [1] * 100 + [2, 3])715 self.assertRaises(self.failureException, self.assertItemsEqual,716 [1, "2", "a", "a"], ["a", "2", True, 1])717 self.assertRaises(self.failureException, self.assertItemsEqual,718 [10], [10, 11])719 self.assertRaises(self.failureException, self.assertItemsEqual,720 [10, 11], [10])721 self.assertRaises(self.failureException, self.assertItemsEqual,722 [10, 11, 10], [10, 11])723724 # Test that sequences of unhashable objects can be tested for sameness:725 self.assertItemsEqual([[1, 2], [3, 4], 0], [False, [3, 4], [1, 2]])726 # Test that iterator of unhashable objects can be tested for sameness:727 self.assertItemsEqual(iter([1, 2, [], 3, 4]),728 iter([1, 2, [], 3, 4]))729730 # hashable types, but not orderable731 self.assertRaises(self.failureException, self.assertItemsEqual,732 [], [divmod, 'x', 1, 5j, 2j, frozenset()])733 # comparing dicts734 self.assertItemsEqual([{'a': 1}, {'b': 2}], [{'b': 2}, {'a': 1}])735 # comparing heterogenous non-hashable sequences736 self.assertItemsEqual([1, 'x', divmod, []], [divmod, [], 'x', 1])737 self.assertRaises(self.failureException, self.assertItemsEqual,738 [], [divmod, [], 'x', 1, 5j, 2j, set()])739 self.assertRaises(self.failureException, self.assertItemsEqual,740 [[1]], [[2]])741742 # Same elements, but not same sequence length743 self.assertRaises(self.failureException, self.assertItemsEqual,744 [1, 1, 2], [2, 1])745 self.assertRaises(self.failureException, self.assertItemsEqual,746 [1, 1, "2", "a", "a"], ["2", "2", True, "a"])747 self.assertRaises(self.failureException, self.assertItemsEqual,748 [1, {'b': 2}, None, True], [{'b': 2}, True, None])749750 # Same elements which don't reliably compare, in751 # different order, see issue 10242752 a = [{2,4}, {1,2}]753 b = a[::-1]754 self.assertItemsEqual(a, b)755756 # test utility functions supporting assertItemsEqual()757758 diffs = set(unittest.util._count_diff_all_purpose('aaabccd', 'abbbcce'))759 expected = {(3,1,'a'), (1,3,'b'), (1,0,'d'), (0,1,'e')}760 self.assertEqual(diffs, expected)761762 diffs = unittest.util._count_diff_all_purpose([[]], [])763 self.assertEqual(diffs, [(1, 0, [])])764765 diffs = set(unittest.util._count_diff_hashable('aaabccd', 'abbbcce'))766 expected = {(3,1,'a'), (1,3,'b'), (1,0,'d'), (0,1,'e')}767 self.assertEqual(diffs, expected)768769 def testAssertSetEqual(self):770 set1 = set()771 set2 = set()772 self.assertSetEqual(set1, set2)773774 self.assertRaises(self.failureException, self.assertSetEqual, None, set2)775 self.assertRaises(self.failureException, self.assertSetEqual, [], set2)776 self.assertRaises(self.failureException, self.assertSetEqual, set1, None)777 self.assertRaises(self.failureException, self.assertSetEqual, set1, [])778779 set1 = set(['a'])780 set2 = set()781 self.assertRaises(self.failureException, self.assertSetEqual, set1, set2)782783 set1 = set(['a'])784 set2 = set(['a'])785 self.assertSetEqual(set1, set2)786787 set1 = set(['a'])788 set2 = set(['a', 'b'])789 self.assertRaises(self.failureException, self.assertSetEqual, set1, set2)790791 set1 = set(['a'])792 set2 = frozenset(['a', 'b'])793 self.assertRaises(self.failureException, self.assertSetEqual, set1, set2)794795 set1 = set(['a', 'b'])796 set2 = frozenset(['a', 'b'])797 self.assertSetEqual(set1, set2)798799 set1 = set()800 set2 = "foo"801 self.assertRaises(self.failureException, self.assertSetEqual, set1, set2)802 self.assertRaises(self.failureException, self.assertSetEqual, set2, set1)803804 # make sure any string formatting is tuple-safe805 set1 = set([(0, 1), (2, 3)])806 set2 = set([(4, 5)])807 self.assertRaises(self.failureException, self.assertSetEqual, set1, set2)808809 def testInequality(self):810 # Try ints811 self.assertGreater(2, 1)812 self.assertGreaterEqual(2, 1)813 self.assertGreaterEqual(1, 1)814 self.assertLess(1, 2)815 self.assertLessEqual(1, 2)816 self.assertLessEqual(1, 1)817 self.assertRaises(self.failureException, self.assertGreater, 1, 2)818 self.assertRaises(self.failureException, self.assertGreater, 1, 1)819 self.assertRaises(self.failureException, self.assertGreaterEqual, 1, 2)820 self.assertRaises(self.failureException, self.assertLess, 2, 1)821 self.assertRaises(self.failureException, self.assertLess, 1, 1)822 self.assertRaises(self.failureException, self.assertLessEqual, 2, 1)823824 # Try Floats825 self.assertGreater(1.1, 1.0)826 self.assertGreaterEqual(1.1, 1.0)827 self.assertGreaterEqual(1.0, 1.0)828 self.assertLess(1.0, 1.1)829 self.assertLessEqual(1.0, 1.1)830 self.assertLessEqual(1.0, 1.0)831 self.assertRaises(self.failureException, self.assertGreater, 1.0, 1.1)832 self.assertRaises(self.failureException, self.assertGreater, 1.0, 1.0)833 self.assertRaises(self.failureException, self.assertGreaterEqual, 1.0, 1.1)834 self.assertRaises(self.failureException, self.assertLess, 1.1, 1.0)835 self.assertRaises(self.failureException, self.assertLess, 1.0, 1.0)836 self.assertRaises(self.failureException, self.assertLessEqual, 1.1, 1.0)837838 # Try Strings839 self.assertGreater('bug', 'ant')840 self.assertGreaterEqual('bug', 'ant')841 self.assertGreaterEqual('ant', 'ant')842 self.assertLess('ant', 'bug')843 self.assertLessEqual('ant', 'bug')844 self.assertLessEqual('ant', 'ant')845 self.assertRaises(self.failureException, self.assertGreater, 'ant', 'bug')846 self.assertRaises(self.failureException, self.assertGreater, 'ant', 'ant')847 self.assertRaises(self.failureException, self.assertGreaterEqual, 'ant', 'bug')848 self.assertRaises(self.failureException, self.assertLess, 'bug', 'ant')849 self.assertRaises(self.failureException, self.assertLess, 'ant', 'ant')850 self.assertRaises(self.failureException, self.assertLessEqual, 'bug', 'ant')851852 # Try Unicode853 self.assertGreater(u'bug', u'ant')854 self.assertGreaterEqual(u'bug', u'ant')855 self.assertGreaterEqual(u'ant', u'ant')856 self.assertLess(u'ant', u'bug')857 self.assertLessEqual(u'ant', u'bug')858 self.assertLessEqual(u'ant', u'ant')859 self.assertRaises(self.failureException, self.assertGreater, u'ant', u'bug')860 self.assertRaises(self.failureException, self.assertGreater, u'ant', u'ant')861 self.assertRaises(self.failureException, self.assertGreaterEqual, u'ant',862 u'bug')863 self.assertRaises(self.failureException, self.assertLess, u'bug', u'ant')864 self.assertRaises(self.failureException, self.assertLess, u'ant', u'ant')865 self.assertRaises(self.failureException, self.assertLessEqual, u'bug', u'ant')866867 # Try Mixed String/Unicode868 self.assertGreater('bug', u'ant')869 self.assertGreater(u'bug', 'ant')870 self.assertGreaterEqual('bug', u'ant')871 self.assertGreaterEqual(u'bug', 'ant')872 self.assertGreaterEqual('ant', u'ant')873 self.assertGreaterEqual(u'ant', 'ant')874 self.assertLess('ant', u'bug')875 self.assertLess(u'ant', 'bug')876 self.assertLessEqual('ant', u'bug')877 self.assertLessEqual(u'ant', 'bug')878 self.assertLessEqual('ant', u'ant')879 self.assertLessEqual(u'ant', 'ant')880 self.assertRaises(self.failureException, self.assertGreater, 'ant', u'bug')881 self.assertRaises(self.failureException, self.assertGreater, u'ant', 'bug')882 self.assertRaises(self.failureException, self.assertGreater, 'ant', u'ant')883 self.assertRaises(self.failureException, self.assertGreater, u'ant', 'ant')884 self.assertRaises(self.failureException, self.assertGreaterEqual, 'ant',885 u'bug')886 self.assertRaises(self.failureException, self.assertGreaterEqual, u'ant',887 'bug')888 self.assertRaises(self.failureException, self.assertLess, 'bug', u'ant')889 self.assertRaises(self.failureException, self.assertLess, u'bug', 'ant')890 self.assertRaises(self.failureException, self.assertLess, 'ant', u'ant')891 self.assertRaises(self.failureException, self.assertLess, u'ant', 'ant')892 self.assertRaises(self.failureException, self.assertLessEqual, 'bug', u'ant')893 self.assertRaises(self.failureException, self.assertLessEqual, u'bug', 'ant')894895 def testAssertMultiLineEqual(self):896 sample_text = b"""\897http://www.python.org/doc/2.3/lib/module-unittest.html898test case899 A test case is the smallest unit of testing. [...]900"""901 revised_sample_text = b"""\902http://www.python.org/doc/2.4.1/lib/module-unittest.html903test case904 A test case is the smallest unit of testing. [...] You may provide your905 own implementation that does not subclass from TestCase, of course.906"""907 sample_text_error = b"""\908- http://www.python.org/doc/2.3/lib/module-unittest.html909? ^910+ http://www.python.org/doc/2.4.1/lib/module-unittest.html911? ^^^912 test case913- A test case is the smallest unit of testing. [...]914+ A test case is the smallest unit of testing. [...] You may provide your915? +++++++++++++++++++++916+ own implementation that does not subclass from TestCase, of course.917"""918 self.maxDiff = None919 for type_changer in (lambda x: x, lambda x: x.decode('utf8')):920 try:921 self.assertMultiLineEqual(type_changer(sample_text),922 type_changer(revised_sample_text))923 except self.failureException, e:924 # need to remove the first line of the error message925 error = str(e).encode('utf8').split('\n', 1)[1]926927 # assertMultiLineEqual is hooked up as the default for928 # unicode strings - so we can't use it for this check929 self.assertTrue(sample_text_error == error)930931 def testAsertEqualSingleLine(self):932 sample_text = u"laden swallows fly slowly"933 revised_sample_text = u"unladen swallows fly quickly"934 sample_text_error = """\935- laden swallows fly slowly936? ^^^^937+ unladen swallows fly quickly938? ++ ^^^^^939"""940 try:941 self.assertEqual(sample_text, revised_sample_text)942 except self.failureException as e:943 error = str(e).split('\n', 1)[1]944 self.assertTrue(sample_text_error == error)945946 def testAssertIsNone(self):947 self.assertIsNone(None)948 self.assertRaises(self.failureException, self.assertIsNone, False)949 self.assertIsNotNone('DjZoPloGears on Rails')950 self.assertRaises(self.failureException, self.assertIsNotNone, None)951952 def testAssertRegexpMatches(self):953 self.assertRegexpMatches('asdfabasdf', r'ab+')954 self.assertRaises(self.failureException, self.assertRegexpMatches,955 'saaas', r'aaaa')956957 def testAssertRaisesCallable(self):958 class ExceptionMock(Exception):959 pass960 def Stub():961 raise ExceptionMock('We expect')962 self.assertRaises(ExceptionMock, Stub)963 # A tuple of exception classes is accepted964 self.assertRaises((ValueError, ExceptionMock), Stub)965 # *args and **kwargs also work966 self.assertRaises(ValueError, int, '19', base=8)967 # Failure when no exception is raised968 with self.assertRaises(self.failureException):969 self.assertRaises(ExceptionMock, lambda: 0)970 # Failure when another exception is raised971 with self.assertRaises(ExceptionMock):972 self.assertRaises(ValueError, Stub)973974 def testAssertRaisesContext(self):975 class ExceptionMock(Exception):976 pass977 def Stub():978 raise ExceptionMock('We expect')979 with self.assertRaises(ExceptionMock):980 Stub()981 # A tuple of exception classes is accepted982 with self.assertRaises((ValueError, ExceptionMock)) as cm:983 Stub()984 # The context manager exposes caught exception985 self.assertIsInstance(cm.exception, ExceptionMock)986 self.assertEqual(cm.exception.args[0], 'We expect')987 # *args and **kwargs also work988 with self.assertRaises(ValueError):989 int('19', base=8)990 # Failure when no exception is raised991 with self.assertRaises(self.failureException):992 with self.assertRaises(ExceptionMock):993 pass994 # Failure when another exception is raised995 with self.assertRaises(ExceptionMock):996 self.assertRaises(ValueError, Stub)997998 def testAssertRaisesRegexp(self):999 class ExceptionMock(Exception):1000 pass10011002 def Stub():1003 raise ExceptionMock('We expect')10041005 self.assertRaisesRegexp(ExceptionMock, re.compile('expect$'), Stub)1006 self.assertRaisesRegexp(ExceptionMock, 'expect$', Stub)1007 self.assertRaisesRegexp(ExceptionMock, u'expect$', Stub)10081009 def testAssertNotRaisesRegexp(self):1010 self.assertRaisesRegexp(1011 self.failureException, '^Exception not raised$',1012 self.assertRaisesRegexp, Exception, re.compile('x'),1013 lambda: None)1014 self.assertRaisesRegexp(1015 self.failureException, '^Exception not raised$',1016 self.assertRaisesRegexp, Exception, 'x',1017 lambda: None)1018 self.assertRaisesRegexp(1019 self.failureException, '^Exception not raised$',1020 self.assertRaisesRegexp, Exception, u'x',1021 lambda: None)10221023 def testAssertRaisesRegexpInvalidRegexp(self):1024 # Issue 20145.1025 class MyExc(Exception):1026 pass1027 self.assertRaises(TypeError, self.assertRaisesRegexp, MyExc, lambda: True)10281029 def testAssertRaisesRegexpMismatch(self):1030 def Stub():1031 raise Exception('Unexpected')10321033 self.assertRaisesRegexp(1034 self.failureException,1035 r'"\^Expected\$" does not match "Unexpected"',1036 self.assertRaisesRegexp, Exception, '^Expected$',1037 Stub)1038 self.assertRaisesRegexp(1039 self.failureException,1040 r'"\^Expected\$" does not match "Unexpected"',1041 self.assertRaisesRegexp, Exception, u'^Expected$',1042 Stub)1043 self.assertRaisesRegexp(1044 self.failureException,1045 r'"\^Expected\$" does not match "Unexpected"',1046 self.assertRaisesRegexp, Exception,1047 re.compile('^Expected$'), Stub)10481049 def testAssertRaisesExcValue(self):1050 class ExceptionMock(Exception):1051 pass10521053 def Stub(foo):1054 raise ExceptionMock(foo)1055 v = "particular value"10561057 ctx = self.assertRaises(ExceptionMock)1058 with ctx:1059 Stub(v)1060 e = ctx.exception1061 self.assertIsInstance(e, ExceptionMock)1062 self.assertEqual(e.args[0], v)10631064 def testSynonymAssertMethodNames(self):1065 """Test undocumented method name synonyms.10661067 Please do not use these methods names in your own code.10681069 This test confirms their continued existence and functionality1070 in order to avoid breaking existing code.1071 """1072 self.assertNotEquals(3, 5)1073 self.assertEquals(3, 3)1074 self.assertAlmostEquals(2.0, 2.0)1075 self.assertNotAlmostEquals(3.0, 5.0)1076 self.assert_(True)10771078 def testPendingDeprecationMethodNames(self):1079 """Test fail* methods pending deprecation, they will warn in 3.2.10801081 Do not use these methods. They will go away in 3.3.1082 """1083 with test_support.check_warnings():1084 self.failIfEqual(3, 5)1085 self.failUnlessEqual(3, 3)1086 self.failUnlessAlmostEqual(2.0, 2.0)1087 self.failIfAlmostEqual(3.0, 5.0)1088 self.failUnless(True)1089 self.failUnlessRaises(TypeError, lambda _: 3.14 + u'spam')1090 self.failIf(False)10911092 def testDeepcopy(self):1093 # Issue: 56601094 class TestableTest(unittest.TestCase):1095 def testNothing(self):1096 pass10971098 test = TestableTest('testNothing')10991100 # This shouldn't blow up1101 deepcopy(test)11021103 def testKeyboardInterrupt(self):1104 def _raise(self=None):1105 raise KeyboardInterrupt1106 def nothing(self):1107 pass11081109 class Test1(unittest.TestCase):1110 test_something = _raise11111112 class Test2(unittest.TestCase):1113 setUp = _raise1114 test_something = nothing11151116 class Test3(unittest.TestCase):1117 test_something = nothing1118 tearDown = _raise11191120 class Test4(unittest.TestCase):1121 def test_something(self):1122 self.addCleanup(_raise)11231124 for klass in (Test1, Test2, Test3, Test4):1125 with self.assertRaises(KeyboardInterrupt):1126 klass('test_something').run()11271128 def testSystemExit(self):1129 def _raise(self=None):1130 raise SystemExit1131 def nothing(self):1132 pass11331134 class Test1(unittest.TestCase):1135 test_something = _raise11361137 class Test2(unittest.TestCase):1138 setUp = _raise1139 test_something = nothing11401141 class Test3(unittest.TestCase):1142 test_something = nothing1143 tearDown = _raise11441145 class Test4(unittest.TestCase):1146 def test_something(self):1147 self.addCleanup(_raise)11481149 for klass in (Test1, Test2, Test3, Test4):1150 result = unittest.TestResult()1151 klass('test_something').run(result)1152 self.assertEqual(len(result.errors), 1)1153 self.assertEqual(result.testsRun, 1)11541155 def testPickle(self):1156 # Issue 1032611571158 # Can't use TestCase classes defined in Test class as1159 # pickle does not work with inner classes1160 test = unittest.TestCase('run')1161 for protocol in range(pickle.HIGHEST_PROTOCOL + 1):11621163 # blew up prior to fix1164 pickled_test = pickle.dumps(test, protocol=protocol)11651166 unpickled_test = pickle.loads(pickled_test)1167 self.assertEqual(test, unpickled_test)116811691170if __name__ == '__main__': ...

Full Screen

Full Screen

failurereason.py

Source:failurereason.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2# $Id: failurereason.py $3"""4Test Manager - Failure Reasons.5"""6__copyright__ = \7"""8Copyright (C) 2012-2015 Oracle Corporation9This file is part of VirtualBox Open Source Edition (OSE), as10available from http://www.virtualbox.org. This file is free software;11you can redistribute it and/or modify it under the terms of the GNU12General Public License (GPL) as published by the Free Software13Foundation, in version 2 as it comes in the "COPYING" file of the14VirtualBox OSE distribution. VirtualBox OSE is distributed in the15hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.16The contents of this file may alternatively be used under the terms17of the Common Development and Distribution License Version 1.018(CDDL) only, as it comes in the "COPYING.CDDL" file of the19VirtualBox OSE distribution, in which case the provisions of the20CDDL are applicable instead of those of the GPL.21You may elect to license modified versions of this file under the22terms and conditions of either the GPL or the CDDL or both.23"""24__version__ = "$Revision: 100880 $"25# Validation Kit imports.26from testmanager.core.base import ModelDataBase, ModelLogicBase, TMExceptionBase27class FailureReasonData(ModelDataBase):28 """29 Failure Reason Data.30 """31 ksIdAttr = 'idFailureReason';32 ksParam_idFailureReason = 'FailureReasonData_idFailureReason'33 ksParam_tsEffective = 'FailureReasonData_tsEffective'34 ksParam_tsExpire = 'FailureReasonData_tsExpire'35 ksParam_uidAuthor = 'FailureReasonData_uidAuthor'36 ksParam_idFailureCategory = 'FailureReasonData_idFailureCategory'37 ksParam_sShort = 'FailureReasonData_sShort'38 ksParam_sFull = 'FailureReasonData_sFull'39 ksParam_iTicket = 'FailureReasonData_iTicket'40 ksParam_asUrls = 'FailureReasonData_asUrls'41 kasAllowNullAttributes = [ 'idFailureReason', 'tsEffective', 'tsExpire',42 'uidAuthor', 'iTicket', 'asUrls' ]43 def __init__(self):44 ModelDataBase.__init__(self);45 #46 # Initialize with defaults.47 # See the database for explanations of each of these fields.48 #49 self.idFailureReason = None50 self.tsEffective = None51 self.tsExpire = None52 self.uidAuthor = None53 self.idFailureCategory = None54 self.sShort = None55 self.sFull = None56 self.iTicket = None57 self.asUrls = None58 def initFromDbRow(self, aoRow):59 """60 Re-initializes the data with a row from a SELECT * FROM FailureReasons.61 Returns self. Raises exception if the row is None or otherwise invalid.62 """63 if aoRow is None:64 raise TMExceptionBase('Failure Reason not found.');65 self.idFailureReason = aoRow[0]66 self.tsEffective = aoRow[1]67 self.tsExpire = aoRow[2]68 self.uidAuthor = aoRow[3]69 self.idFailureCategory = aoRow[4]70 self.sShort = aoRow[5]71 self.sFull = aoRow[6]72 self.iTicket = aoRow[7]73 self.asUrls = aoRow[8]74 return self75class FailureReasonLogic(ModelLogicBase): # pylint: disable=R090376 """77 Failure Reason logic.78 """79 def fetchForListing(self, iStart, cMaxRows, tsNow):80 """81 Fetches Failure Category records.82 Returns an array (list) of FailureReasonData items, empty list if none.83 Raises exception on error.84 """85 if tsNow is None:86 self._oDb.execute('SELECT *\n'87 'FROM FailureReasons\n'88 'WHERE tsExpire = \'infinity\'::TIMESTAMP\n'89 'ORDER BY idFailureReason DESC\n'90 'LIMIT %s OFFSET %s\n'91 , (cMaxRows, iStart,));92 else:93 self._oDb.execute('SELECT *\n'94 'FROM FailureReasons\n'95 'WHERE tsExpire > %s\n'96 ' AND tsEffective <= %s\n'97 'ORDER BY idFailureReason DESC\n'98 'LIMIT %s OFFSET %s\n'99 , (tsNow, tsNow, cMaxRows, iStart,));100 aoRows = []101 for aoRow in self._oDb.fetchAll():102 aoRows.append(FailureReasonData().initFromDbRow(aoRow))103 return aoRows104 def fetchForCombo(self, tsEffective = None):105 """106 Gets the list of Failure Reasons for a combo box.107 Returns an array of (value [idFailureReason], drop-down-name [sShort],108 hover-text [sFull]) tuples.109 """110 if tsEffective is None:111 self._oDb.execute('SELECT idFailureReason, sShort, sFull\n'112 'FROM FailureReasons\n'113 'WHERE tsExpire = \'infinity\'::TIMESTAMP\n'114 'ORDER BY sShort')115 else:116 self._oDb.execute('SELECT idFailureReason, sShort, sFull\n'117 'FROM FailureReasons\n'118 'WHERE tsExpire > %s\n'119 ' AND tsEffective <= %s\n'120 'ORDER BY sShort'121 , (tsEffective, tsEffective))122 return self._oDb.fetchAll()123 def getById(self, idFailureReason):124 """Get Failure Reason data by idFailureReason"""125 self._oDb.execute('SELECT *\n'126 'FROM FailureReasons\n'127 'WHERE tsExpire = \'infinity\'::timestamp\n'128 ' AND idFailureReason = %s;', (idFailureReason,))129 aRows = self._oDb.fetchAll()130 if len(aRows) not in (0, 1):131 raise self._oDb.integrityException(132 'Found more than one failure reasons with the same credentials. Database structure is corrupted.')133 try:134 return FailureReasonData().initFromDbRow(aRows[0])135 except IndexError:136 return None137 def getIdsByCategory(self, idFailureCategory, tsEffective=None):138 """139 Gets the list of Failure Ressons IDs,140 all the items belong to @param idFailureCategory141 """142 if tsEffective is None:143 self._oDb.execute('SELECT idFailureReason\n'144 'FROM FailureReasons\n'145 'WHERE tsExpire = \'infinity\'::TIMESTAMP\n'146 ' AND idFailureCategory = %s\n'147 'ORDER BY idFailureReason DESC'148 , (idFailureCategory,))149 else:150 self._oDb.execute('SELECT idFailureReason\n'151 'FROM FailureReasons\n'152 'WHERE tsExpire > %s\n'153 ' AND tsEffective <= %s\n'154 ' AND idFailureCategory = %s\n'155 'ORDER BY idFailureReason DESC'156 , (tsEffective, tsEffective, idFailureCategory))157 return self._oDb.fetchAll()158 def getAll(self, tsEffective=None):159 """160 Gets the list of all Failure Reasons.161 Returns an array of FailureReasonData instances.162 """163 if tsEffective is None:164 self._oDb.execute('SELECT *\n'165 'FROM FailureReasons\n'166 'WHERE tsExpire = \'infinity\'::TIMESTAMP\n'167 'ORDER BY idFailureReason DESC')168 else:169 self._oDb.execute('SELECT *\n'170 'FROM FailureReasons\n'171 'WHERE tsExpire > %s\n'172 ' AND tsEffective <= %s\n'173 'ORDER BY idFailureReason DESC'174 , (tsEffective, tsEffective))175 aoRet = []176 for aoRow in self._oDb.fetchAll():177 aoRet.append(FailureReasonData().initFromDbRow(aoRow))178 return aoRet179 def addEntry(self, oFailureReasonData, uidAuthor, fCommit=True):180 """Add record to database"""181 # Check if record with the same sShort fiels is already exists182 self._oDb.execute('SELECT *\n'183 'FROM FailureReasons\n'184 'WHERE tsExpire = \'infinity\'::TIMESTAMP\n'185 ' AND sShort = %s\n',186 (oFailureReasonData.sShort,))187 if len(self._oDb.fetchAll()) != 0:188 raise Exception('Record already exist')189 # Add record190 self._oDb.execute('INSERT INTO FailureReasons (\n'191 ' uidAuthor, idFailureCategory,'192 ' sShort, sFull, iTicket, asUrls'193 ')\n'194 'VALUES (%s, %s, %s, %s, %s, %s)',195 (uidAuthor,196 oFailureReasonData.idFailureCategory,197 oFailureReasonData.sShort,198 oFailureReasonData.sFull,199 oFailureReasonData.iTicket,200 oFailureReasonData.asUrls))201 if fCommit:202 self._oDb.commit()203 return True204 def remove(self, uidAuthor, idFailureReason, fNeedCommit=True):205 """206 Historize record207 """208 self._oDb.execute('UPDATE FailureReasons\n'209 'SET tsExpire = CURRENT_TIMESTAMP,\n'210 ' uidAuthor = %s\n'211 'WHERE idFailureReason = %s\n'212 ' AND tsExpire = \'infinity\'::TIMESTAMP\n',213 (uidAuthor, idFailureReason))214 # Also historize Black List records215 self._oDb.execute('UPDATE BuildBlackList\n'216 'SET tsExpire = CURRENT_TIMESTAMP,\n'217 ' uidAuthor = %s\n'218 'WHERE idFailureReason = %s\n'219 ' AND tsExpire = \'infinity\'::TIMESTAMP\n',220 (uidAuthor, idFailureReason))221 if fNeedCommit:222 self._oDb.commit()223 return True224 def editEntry(self, oFailureReasonData, uidAuthor, fCommit=True):225 """Modify database record"""226 # Check if record exists227 oFailureReasonDataOld = self.getById(oFailureReasonData.idFailureReason)228 if oFailureReasonDataOld is None:229 raise TMExceptionBase(230 'Failure Reason (id: %d) does not exist'231 % oFailureReasonData.idFailureReason)232 # Check if anything has been changed233 if oFailureReasonData.isEqual(oFailureReasonDataOld):234 return True235 # Historize record236 self.remove(237 uidAuthor, oFailureReasonData.idFailureReason, fNeedCommit=False)238 # Add new record (keeping its ID)239 self._oDb.execute('INSERT INTO FailureReasons (\n'240 ' idFailureReason,'241 ' uidAuthor,'242 ' idFailureCategory,'243 ' sShort,'244 ' sFull,'245 ' iTicket,'246 ' asUrls'247 ')\n'248 'VALUES (%s, %s, %s, %s, %s, %s, %s)',249 (oFailureReasonData.idFailureReason,250 uidAuthor,251 oFailureReasonData.idFailureCategory,252 oFailureReasonData.sShort,253 oFailureReasonData.sFull,254 oFailureReasonData.iTicket,255 oFailureReasonData.asUrls256 ))257 if fCommit:258 self._oDb.commit()...

Full Screen

Full Screen

failurecategory.py

Source:failurecategory.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2# $Id: failurecategory.py $3"""4Test Manager - Failure Categories.5"""6__copyright__ = \7"""8Copyright (C) 2012-2015 Oracle Corporation9This file is part of VirtualBox Open Source Edition (OSE), as10available from http://www.virtualbox.org. This file is free software;11you can redistribute it and/or modify it under the terms of the GNU12General Public License (GPL) as published by the Free Software13Foundation, in version 2 as it comes in the "COPYING" file of the14VirtualBox OSE distribution. VirtualBox OSE is distributed in the15hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.16The contents of this file may alternatively be used under the terms17of the Common Development and Distribution License Version 1.018(CDDL) only, as it comes in the "COPYING.CDDL" file of the19VirtualBox OSE distribution, in which case the provisions of the20CDDL are applicable instead of those of the GPL.21You may elect to license modified versions of this file under the22terms and conditions of either the GPL or the CDDL or both.23"""24__version__ = "$Revision: 100880 $"25# Validation Kit imports.26from testmanager.core.base import ModelDataBase, ModelLogicBase, TMExceptionBase27from testmanager.core.failurereason import FailureReasonLogic28class FailureCategoryData(ModelDataBase):29 """30 Failure Category Data.31 """32 ksParam_idFailureCategory = 'FailureCategory_idFailureCategory'33 ksParam_tsEffective = 'FailureCategory_tsEffective'34 ksParam_tsExpire = 'FailureCategory_tsExpire'35 ksParam_uidAuthor = 'FailureCategory_uidAuthor'36 ksParam_sShort = 'FailureCategory_sShort'37 ksParam_sFull = 'FailureCategory_sFull'38 kasAllowNullAttributes = [ 'idFailureCategory', 'tsEffective', 'tsExpire', 'uidAuthor' ]39 def __init__(self):40 ModelDataBase.__init__(self);41 #42 # Initialize with defaults.43 # See the database for explanations of each of these fields.44 #45 self.idFailureCategory = None46 self.tsEffective = None47 self.tsExpire = None48 self.uidAuthor = None49 self.sShort = None50 self.sFull = None51 def initFromDbRow(self, aoRow):52 """53 Re-initializes the data with a row from a SELECT * FROM FailureCategoryes.54 Returns self. Raises exception if the row is None or otherwise invalid.55 """56 if aoRow is None:57 raise TMExceptionBase('Failure Category not found.');58 self.idFailureCategory = aoRow[0]59 self.tsEffective = aoRow[1]60 self.tsExpire = aoRow[2]61 self.uidAuthor = aoRow[3]62 self.sShort = aoRow[4]63 self.sFull = aoRow[5]64 return self65class FailureCategoryLogic(ModelLogicBase): # pylint: disable=R090366 """67 Failure Category logic.68 """69 def fetchForListing(self, iStart, cMaxRows, tsNow):70 """71 Fetches Failure Category records.72 Returns an array (list) of FailureCategoryData items, empty list if none.73 Raises exception on error.74 """75 if tsNow is None:76 self._oDb.execute('SELECT *\n'77 'FROM FailureCategories\n'78 'WHERE tsExpire = \'infinity\'::TIMESTAMP\n'79 'ORDER BY idFailureCategory ASC\n'80 'LIMIT %s OFFSET %s\n'81 , (cMaxRows, iStart,));82 else:83 self._oDb.execute('SELECT *\n'84 'FROM FailureCategories\n'85 'WHERE tsExpire > %s\n'86 ' AND tsEffective <= %s\n'87 'ORDER BY idFailureCategory ASC\n'88 'LIMIT %s OFFSET %s\n'89 , (tsNow, tsNow, cMaxRows, iStart,));90 aoRows = []91 for aoRow in self._oDb.fetchAll():92 aoRows.append(FailureCategoryData().initFromDbRow(aoRow))93 return aoRows94 def getFailureCategoriesForCombo(self, tsEffective = None):95 """96 Gets the list of Failure Categories for a combo box.97 Returns an array of (value [idFailureCategory], drop-down-name [sShort],98 hover-text [sFull]) tuples.99 """100 if tsEffective is None:101 self._oDb.execute('SELECT idFailureCategory, sShort, sFull\n'102 'FROM FailureCategories\n'103 'WHERE tsExpire = \'infinity\'::TIMESTAMP\n'104 'ORDER BY sShort')105 else:106 self._oDb.execute('SELECT idFailureCategory, sShort, sFull\n'107 'FROM FailureCategories\n'108 'WHERE tsExpire > %s\n'109 ' AND tsEffective <= %s\n'110 'ORDER BY sShort'111 , (tsEffective, tsEffective))112 return self._oDb.fetchAll()113 def getById(self, idFailureCategory):114 """Get Failure Category data by idFailureCategory"""115 self._oDb.execute('SELECT *\n'116 'FROM FailureCategories\n'117 'WHERE tsExpire = \'infinity\'::timestamp\n'118 ' AND idFailureCategory = %s;', (idFailureCategory,))119 aRows = self._oDb.fetchAll()120 if len(aRows) not in (0, 1):121 raise self._oDb.integrityException(122 'Found more than one failure categories with the same credentials. Database structure is corrupted.')123 try:124 return FailureCategoryData().initFromDbRow(aRows[0])125 except IndexError:126 return None127 def addEntry(self, oFailureCategoryData, uidAuthor, fCommit=True):128 """129 Add Failure Category record130 """131 # Check if record with the same sShort fiels is already exists132 self._oDb.execute('SELECT *\n'133 'FROM FailureCategories\n'134 'WHERE tsExpire = \'infinity\'::TIMESTAMP\n'135 ' AND sShort = %s\n',136 (oFailureCategoryData.sShort,))137 if len(self._oDb.fetchAll()) != 0:138 raise Exception('Record already exist')139 # Add record140 self._oDb.execute('INSERT INTO FailureCategories (\n'141 ' uidAuthor, sShort, sFull'142 ')\n'143 'VALUES (%s, %s, %s)',144 (uidAuthor,145 oFailureCategoryData.sShort,146 oFailureCategoryData.sFull))147 if fCommit:148 self._oDb.commit()149 return True150 def remove(self, uidAuthor, idFailureCategory, fNeedCommit=True):151 """152 Historize record153 """154 # Historize Failure Reasons records first155 self._oDb.execute('SELECT idFailureReason\n'156 'FROM FailureReasons\n'157 'WHERE idFailureCategory = %s\n'158 ' AND tsExpire = \'infinity\'::TIMESTAMP\n',159 (idFailureCategory,))160 for iFailureReasonId in self._oDb.fetchAll():161 FailureReasonLogic(self._oDb).remove(162 uidAuthor, iFailureReasonId, fNeedCommit=False)163 self._oDb.execute('UPDATE FailureCategories\n'164 'SET tsExpire = CURRENT_TIMESTAMP,\n'165 ' uidAuthor = %s\n'166 'WHERE idFailureCategory = %s\n'167 ' AND tsExpire = \'infinity\'::TIMESTAMP\n',168 (uidAuthor, idFailureCategory))169 if fNeedCommit:170 self._oDb.commit()171 return True172 def editEntry(self, oFailureCategoryData, uidAuthor, fCommit=True):173 """Modify database record"""174 # Check if record exists175 oFailureCategoryDataOld = self.getById(oFailureCategoryData.idFailureCategory)176 if oFailureCategoryDataOld is None:177 raise TMExceptionBase(178 'Failure Category (id: %d) does not exist'179 % oFailureCategoryData.idFailureCategory)180 # Check if anything has been changed181 if oFailureCategoryData.isEqual(oFailureCategoryDataOld):182 return True183 # Historize record184 self.remove(185 uidAuthor, oFailureCategoryData.idFailureCategory, fNeedCommit=False)186 self._oDb.execute('INSERT INTO FailureCategories (\n'187 ' idFailureCategory, uidAuthor, sShort, sFull'188 ')\n'189 'VALUES (%s, %s, %s, %s)',190 (oFailureCategoryData.idFailureCategory,191 uidAuthor,192 oFailureCategoryData.sShort,193 oFailureCategoryData.sFull))194 if fCommit:195 self._oDb.commit()...

Full Screen

Full Screen

test_failures.py

Source:test_failures.py Github

copy

Full Screen

...26# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE27# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.28import cPickle29from webkitpy.layout_tests.models import test_expectations30def is_reftest_failure(failure_list):31 failure_types = [type(f) for f in failure_list]32 return set((FailureReftestMismatch, FailureReftestMismatchDidNotOccur, FailureReftestNoImagesGenerated)).intersection(failure_types)33# FIXME: This is backwards. Each TestFailure subclass should know what34# test_expectation type it corresponds too. Then this method just35# collects them all from the failure list and returns the worst one.36def determine_result_type(failure_list):37 """Takes a set of test_failures and returns which result type best fits38 the list of failures. "Best fits" means we use the worst type of failure.39 Returns:40 one of the test_expectations result types - PASS, FAIL, CRASH, etc."""41 if not failure_list or len(failure_list) == 0:42 return test_expectations.PASS43 failure_types = [type(f) for f in failure_list]44 if FailureCrash in failure_types:45 return test_expectations.CRASH46 elif FailureLeak in failure_types:47 return test_expectations.LEAK48 elif FailureTimeout in failure_types:49 return test_expectations.TIMEOUT50 elif FailureEarlyExit in failure_types:51 return test_expectations.SKIP52 elif (FailureMissingResult in failure_types or53 FailureMissingImage in failure_types or54 FailureMissingImageHash in failure_types or55 FailureMissingAudio in failure_types):56 return test_expectations.MISSING57 else:58 is_text_failure = (FailureTextMismatch in failure_types or59 FailureTestHarnessAssertion in failure_types)60 is_image_failure = (FailureImageHashIncorrect in failure_types or61 FailureImageHashMismatch in failure_types)62 is_audio_failure = (FailureAudioMismatch in failure_types)63 if is_text_failure and is_image_failure:64 return test_expectations.IMAGE_PLUS_TEXT65 elif is_text_failure:66 return test_expectations.TEXT67 elif is_image_failure or is_reftest_failure(failure_list):68 return test_expectations.IMAGE69 elif is_audio_failure:70 return test_expectations.AUDIO71 else:72 raise ValueError("unclassifiable set of failures: "73 + str(failure_types))74class TestFailure(object):75 """Abstract base class that defines the failure interface."""76 @staticmethod77 def loads(s):78 """Creates a TestFailure object from the specified string."""79 return cPickle.loads(s)80 def message(self):81 """Returns a string describing the failure in more detail."""...

Full Screen

Full Screen

wuiadminfailurereason.py

Source:wuiadminfailurereason.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2# $Id: wuiadminfailurereason.py $3"""4Test Manager WUI - Failure Reasons Web content generator.5"""6__copyright__ = \7"""8Copyright (C) 2012-2015 Oracle Corporation9This file is part of VirtualBox Open Source Edition (OSE), as10available from http://www.virtualbox.org. This file is free software;11you can redistribute it and/or modify it under the terms of the GNU12General Public License (GPL) as published by the Free Software13Foundation, in version 2 as it comes in the "COPYING" file of the14VirtualBox OSE distribution. VirtualBox OSE is distributed in the15hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.16The contents of this file may alternatively be used under the terms17of the Common Development and Distribution License Version 1.018(CDDL) only, as it comes in the "COPYING.CDDL" file of the19VirtualBox OSE distribution, in which case the provisions of the20CDDL are applicable instead of those of the GPL.21You may elect to license modified versions of this file under the22terms and conditions of either the GPL or the CDDL or both.23"""24__version__ = "$Revision: 100880 $"25# Validation Kit imports.26from testmanager.webui.wuibase import WuiException27from testmanager.webui.wuicontentbase import WuiFormContentBase, WuiListContentBase, WuiTmLink28from testmanager.core.failurereason import FailureReasonData29from testmanager.core.failurecategory import FailureCategoryLogic30from testmanager.core.db import TMDatabaseConnection31class WuiAdminFailureReason(WuiFormContentBase):32 """33 WUI Failure Reason HTML content generator.34 """35 def __init__(self, oFailureReasonData, sMode, oDisp):36 """37 Prepare & initialize parent38 """39 if sMode == WuiFormContentBase.ksMode_Add:40 sTitle = 'Add Failure Reason'41 sSubmitAction = oDisp.ksActionFailureReasonAdd42 elif sMode == WuiFormContentBase.ksMode_Edit:43 sTitle = 'Edit Failure Reason'44 sSubmitAction = oDisp.ksActionFailureReasonEdit45 else:46 raise WuiException('Unknown parameter')47 WuiFormContentBase.__init__(self, oFailureReasonData, sMode, 'FailureReason', oDisp, sTitle,48 sSubmitAction = sSubmitAction, fEditable = False); ## @todo non-standard action names.49 def _populateForm(self, oForm, oData):50 """51 Construct an HTML form52 """53 aoFailureCategories = FailureCategoryLogic(TMDatabaseConnection()).getFailureCategoriesForCombo()54 if len(aoFailureCategories) == 0:55 from testmanager.webui.wuiadmin import WuiAdmin56 sExceptionMsg = 'Please <a href="%s?%s=%s">add</a> Failure Category first.' % \57 (WuiAdmin.ksScriptName, WuiAdmin.ksParamAction, WuiAdmin.ksActionFailureCategoryShowAdd)58 raise WuiException(sExceptionMsg)59 oForm.addIntRO (FailureReasonData.ksParam_idFailureReason, oData.idFailureReason, 'Failure Reason ID')60 oForm.addTimestampRO (FailureReasonData.ksParam_tsEffective, oData.tsEffective, 'Last changed')61 oForm.addTimestampRO (FailureReasonData.ksParam_tsExpire, oData.tsExpire, 'Expires (excl)')62 oForm.addIntRO (FailureReasonData.ksParam_uidAuthor, oData.uidAuthor, 'Changed by UID')63 oForm.addComboBox (FailureReasonData.ksParam_idFailureCategory, oData.idFailureCategory, 'Failure Category',64 aoFailureCategories)65 oForm.addText (FailureReasonData.ksParam_sShort, oData.sShort, 'Short Description')66 oForm.addText (FailureReasonData.ksParam_sFull, oData.sFull, 'Full Description')67 oForm.addInt (FailureReasonData.ksParam_iTicket, oData.iTicket, 'Ticket Number')68 oForm.addMultilineText(FailureReasonData.ksParam_asUrls, oData.asUrls, 'Other URLs to reports '69 'or discussions of the '70 'observed symptoms')71 oForm.addSubmit()72 return True73class WuiAdminFailureReasonList(WuiListContentBase):74 """75 WUI Admin Failure Reasons Content Generator.76 """77 def __init__(self, aoEntries, iPage, cItemsPerPage, tsEffective, fnDPrint, oDisp):78 WuiListContentBase.__init__(self, aoEntries, iPage, cItemsPerPage, tsEffective,79 sTitle = 'Failure Reasons', sId = 'failureReasons',80 fnDPrint = fnDPrint, oDisp = oDisp);81 self._asColumnHeaders = ['ID', 'Category', 'Short Description',82 'Full Description', 'Ticket', 'External References', 'Actions' ]83 self._asColumnAttribs = ['align="right"', 'align="center"', 'align="center"',84 'align="center"',' align="center"', 'align="center"', 'align="center"']85 def _formatListEntry(self, iEntry):86 from testmanager.webui.wuiadmin import WuiAdmin87 oEntry = self._aoEntries[iEntry]88 return [ oEntry.idFailureReason,89 oEntry.idFailureCategory,90 oEntry.sShort,91 oEntry.sFull,92 oEntry.iTicket,93 oEntry.asUrls,94 [ WuiTmLink('Modify', WuiAdmin.ksScriptName,95 { WuiAdmin.ksParamAction: WuiAdmin.ksActionFailureReasonShowEdit,96 FailureReasonData.ksParam_idFailureReason: oEntry.idFailureReason } ),97 WuiTmLink('Remove', WuiAdmin.ksScriptName,98 { WuiAdmin.ksParamAction: WuiAdmin.ksActionFailureReasonDel,99 FailureReasonData.ksParam_idFailureReason: oEntry.idFailureReason },100 sConfirm = 'Are you sure you want to remove failure reason #%d?' % (oEntry.idFailureReason,)),...

Full Screen

Full Screen

ToolError.py

Source:ToolError.py Github

copy

Full Screen

1## @file2# Standardized Error Hanlding infrastructures.3#4# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>5#6# This program and the accompanying materials are licensed and made available 7# under the terms and conditions of the BSD License which accompanies this 8# distribution. The full text of the license may be found at 9# http://opensource.org/licenses/bsd-license.php10#11# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,12# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.13#14'''15ToolError16'''17import Logger.StringTable as ST18FILE_OPEN_FAILURE = 119FILE_WRITE_FAILURE = 220FILE_PARSE_FAILURE = 321FILE_READ_FAILURE = 422FILE_CREATE_FAILURE = 523FILE_CHECKSUM_FAILURE = 624FILE_COMPRESS_FAILURE = 725FILE_DECOMPRESS_FAILURE = 826FILE_MOVE_FAILURE = 927FILE_DELETE_FAILURE = 1028FILE_COPY_FAILURE = 1129FILE_POSITIONING_FAILURE = 1230FILE_ALREADY_EXIST = 1331FILE_NOT_FOUND = 1432FILE_TYPE_MISMATCH = 1533FILE_CASE_MISMATCH = 1634FILE_DUPLICATED = 1735FILE_UNKNOWN_ERROR = 0x0FFF36OPTION_UNKNOWN = 0x100037OPTION_MISSING = 0x100138OPTION_CONFLICT = 0x100239OPTION_VALUE_INVALID = 0x100340OPTION_DEPRECATED = 0x100441OPTION_NOT_SUPPORTED = 0x100542OPTION_UNKNOWN_ERROR = 0x1FFF43PARAMETER_INVALID = 0x200044PARAMETER_MISSING = 0x200145PARAMETER_UNKNOWN_ERROR = 0x2FFF46FORMAT_INVALID = 0x300047FORMAT_NOT_SUPPORTED = 0x300148FORMAT_UNKNOWN = 0x300249FORMAT_UNKNOWN_ERROR = 0x3FFF50RESOURCE_NOT_AVAILABLE = 0x400051RESOURCE_ALLOCATE_FAILURE = 0x400152RESOURCE_FULL = 0x400253RESOURCE_OVERFLOW = 0x400354RESOURCE_UNDERRUN = 0x400455RESOURCE_UNKNOWN_ERROR = 0x4FFF56ATTRIBUTE_NOT_AVAILABLE = 0x500057ATTRIBUTE_GET_FAILURE = 0x500158ATTRIBUTE_SET_FAILURE = 0x500259ATTRIBUTE_UPDATE_FAILURE = 0x500360ATTRIBUTE_ACCESS_DENIED = 0x500461ATTRIBUTE_RETRIEVE_FAILURE = 0x500562ATTRIBUTE_UNKNOWN_ERROR = 0x5FFF63ATTRIBUTE_RETRIEVE_FAILURE = 0x5F0064IO_NOT_READY = 0x600065IO_BUSY = 0x600166IO_TIMEOUT = 0x600267IO_UNKNOWN_ERROR = 0x6FFF68COMMAND_FAILURE = 0x700069CODE_ERROR = 0xC0DE70AUTOGEN_ERROR = 0xF00071PARSER_ERROR = 0xF00172BUILD_ERROR = 0xF00273GENFDS_ERROR = 0xF00374ECC_ERROR = 0xF00475EOT_ERROR = 0xF00576DDC_ERROR = 0xF00977WARNING_AS_ERROR = 0xF00678MIGRATION_ERROR = 0xF01079EDK1_INF_ERROR = 0xF01180ABORT_ERROR = 0xFFFE81UNKNOWN_ERROR = 0xFFFF82UPT_ALREADY_INSTALLED_ERROR = 0xD00083UPT_ENVIRON_MISSING_ERROR = 0xD00184UPT_REPKG_ERROR = 0xD00285UPT_ALREADY_RUNNING_ERROR = 0xD00386UPT_MUL_DEC_ERROR = 0xD00487UPT_DB_UPDATE_ERROR = 0xD00588UPT_INI_PARSE_ERROR = 0xE00089## Error message of each error code90#91gERROR_MESSAGE = {92 FILE_NOT_FOUND : ST.ERR_FILE_NOT_FOUND,93 FILE_OPEN_FAILURE : ST.ERR_FILE_OPEN_FAILURE,94 FILE_WRITE_FAILURE : ST.ERR_FILE_WRITE_FAILURE,95 FILE_PARSE_FAILURE : ST.ERR_FILE_PARSE_FAILURE,96 FILE_READ_FAILURE : ST.ERR_FILE_READ_FAILURE,97 FILE_CREATE_FAILURE : ST.ERR_FILE_CREATE_FAILURE,98 FILE_CHECKSUM_FAILURE : ST.ERR_FILE_CHECKSUM_FAILURE,99 FILE_COMPRESS_FAILURE : ST.ERR_FILE_COMPRESS_FAILURE,100 FILE_DECOMPRESS_FAILURE : ST.ERR_FILE_DECOMPRESS_FAILURE,101 FILE_MOVE_FAILURE : ST.ERR_FILE_MOVE_FAILURE,102 FILE_DELETE_FAILURE : ST.ERR_FILE_DELETE_FAILURE,103 FILE_COPY_FAILURE : ST.ERR_FILE_COPY_FAILURE,104 FILE_POSITIONING_FAILURE: ST.ERR_FILE_POSITIONING_FAILURE,105 FILE_ALREADY_EXIST : ST.ERR_FILE_ALREADY_EXIST,106 FILE_TYPE_MISMATCH : ST.ERR_FILE_TYPE_MISMATCH ,107 FILE_CASE_MISMATCH : ST.ERR_FILE_CASE_MISMATCH,108 FILE_DUPLICATED : ST.ERR_FILE_DUPLICATED,109 FILE_UNKNOWN_ERROR : ST.ERR_FILE_UNKNOWN_ERROR,110 OPTION_UNKNOWN : ST.ERR_OPTION_UNKNOWN,111 OPTION_MISSING : ST.ERR_OPTION_MISSING,112 OPTION_CONFLICT : ST.ERR_OPTION_CONFLICT,113 OPTION_VALUE_INVALID : ST.ERR_OPTION_VALUE_INVALID,114 OPTION_DEPRECATED : ST.ERR_OPTION_DEPRECATED,115 OPTION_NOT_SUPPORTED : ST.ERR_OPTION_NOT_SUPPORTED,116 OPTION_UNKNOWN_ERROR : ST.ERR_OPTION_UNKNOWN_ERROR,117 PARAMETER_INVALID : ST.ERR_PARAMETER_INVALID,118 PARAMETER_MISSING : ST.ERR_PARAMETER_MISSING,119 PARAMETER_UNKNOWN_ERROR : ST.ERR_PARAMETER_UNKNOWN_ERROR,120 FORMAT_INVALID : ST.ERR_FORMAT_INVALID,121 FORMAT_NOT_SUPPORTED : ST.ERR_FORMAT_NOT_SUPPORTED,122 FORMAT_UNKNOWN : ST.ERR_FORMAT_UNKNOWN,123 FORMAT_UNKNOWN_ERROR : ST.ERR_FORMAT_UNKNOWN_ERROR,124 RESOURCE_NOT_AVAILABLE : ST.ERR_RESOURCE_NOT_AVAILABLE,125 RESOURCE_ALLOCATE_FAILURE : ST.ERR_RESOURCE_ALLOCATE_FAILURE,126 RESOURCE_FULL : ST.ERR_RESOURCE_FULL,127 RESOURCE_OVERFLOW : ST.ERR_RESOURCE_OVERFLOW,128 RESOURCE_UNDERRUN : ST.ERR_RESOURCE_UNDERRUN,129 RESOURCE_UNKNOWN_ERROR : ST.ERR_RESOURCE_UNKNOWN_ERROR,130 ATTRIBUTE_NOT_AVAILABLE : ST.ERR_ATTRIBUTE_NOT_AVAILABLE,131 ATTRIBUTE_RETRIEVE_FAILURE : ST.ERR_ATTRIBUTE_RETRIEVE_FAILURE,132 ATTRIBUTE_SET_FAILURE : ST.ERR_ATTRIBUTE_SET_FAILURE,133 ATTRIBUTE_UPDATE_FAILURE: ST.ERR_ATTRIBUTE_UPDATE_FAILURE,134 ATTRIBUTE_ACCESS_DENIED : ST.ERR_ATTRIBUTE_ACCESS_DENIED,135 ATTRIBUTE_UNKNOWN_ERROR : ST.ERR_ATTRIBUTE_UNKNOWN_ERROR,136 COMMAND_FAILURE : ST.ERR_COMMAND_FAILURE,137 IO_NOT_READY : ST.ERR_IO_NOT_READY,138 IO_BUSY : ST.ERR_IO_BUSY,139 IO_TIMEOUT : ST.ERR_IO_TIMEOUT,140 IO_UNKNOWN_ERROR : ST.ERR_IO_UNKNOWN_ERROR,141 UNKNOWN_ERROR : ST.ERR_UNKNOWN_ERROR,142 UPT_ALREADY_INSTALLED_ERROR : ST.ERR_UPT_ALREADY_INSTALLED_ERROR,143 UPT_ENVIRON_MISSING_ERROR : ST.ERR_UPT_ENVIRON_MISSING_ERROR,144 UPT_REPKG_ERROR : ST.ERR_UPT_REPKG_ERROR,145 UPT_ALREADY_RUNNING_ERROR : ST.ERR_UPT_ALREADY_RUNNING_ERROR,146 UPT_MUL_DEC_ERROR : ST.ERR_MUL_DEC_ERROR,147 UPT_INI_PARSE_ERROR : ST.ERR_UPT_INI_PARSE_ERROR,148}149## Exception indicating a fatal error150#151class FatalError(Exception):...

Full Screen

Full Screen

BuildToolError.py

Source:BuildToolError.py Github

copy

Full Screen

1## @file2# Standardized Error Hanlding infrastructures.3#4# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>5# This program and the accompanying materials6# are licensed and made available under the terms and conditions of the BSD License7# which accompanies this distribution. The full text of the license may be found at8# http://opensource.org/licenses/bsd-license.php9#10# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,11# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.12#13FILE_OPEN_FAILURE = 114FILE_WRITE_FAILURE = 215FILE_PARSE_FAILURE = 316FILE_READ_FAILURE = 417FILE_CREATE_FAILURE = 518FILE_CHECKSUM_FAILURE = 619FILE_COMPRESS_FAILURE = 720FILE_DECOMPRESS_FAILURE = 821FILE_MOVE_FAILURE = 922FILE_DELETE_FAILURE = 1023FILE_COPY_FAILURE = 1124FILE_POSITIONING_FAILURE = 1225FILE_ALREADY_EXIST = 1326FILE_NOT_FOUND = 1427FILE_TYPE_MISMATCH = 1528FILE_CASE_MISMATCH = 1629FILE_DUPLICATED = 1730FILE_UNKNOWN_ERROR = 0x0FFF31OPTION_UNKNOWN = 0x100032OPTION_MISSING = 0x100133OPTION_CONFLICT = 0x100234OPTION_VALUE_INVALID = 0x100335OPTION_DEPRECATED = 0x100436OPTION_NOT_SUPPORTED = 0x100537OPTION_UNKNOWN_ERROR = 0x1FFF38PARAMETER_INVALID = 0x200039PARAMETER_MISSING = 0x200140PARAMETER_UNKNOWN_ERROR =0x2FFF41FORMAT_INVALID = 0x300042FORMAT_NOT_SUPPORTED = 0x300143FORMAT_UNKNOWN = 0x300244FORMAT_UNKNOWN_ERROR = 0x3FFF45RESOURCE_NOT_AVAILABLE = 0x400046RESOURCE_ALLOCATE_FAILURE = 0x400147RESOURCE_FULL = 0x400248RESOURCE_OVERFLOW = 0x400349RESOURCE_UNDERRUN = 0x400450RESOURCE_UNKNOWN_ERROR = 0x4FFF51ATTRIBUTE_NOT_AVAILABLE = 0x500052ATTRIBUTE_GET_FAILURE = 0x500153ATTRIBUTE_SET_FAILURE = 0x500254ATTRIBUTE_UPDATE_FAILURE = 0x500355ATTRIBUTE_ACCESS_DENIED = 0x500456ATTRIBUTE_UNKNOWN_ERROR = 0x5FFF57IO_NOT_READY = 0x600058IO_BUSY = 0x600159IO_TIMEOUT = 0x600260IO_UNKNOWN_ERROR = 0x6FFF61COMMAND_FAILURE = 0x700062PERMISSION_FAILURE = 0x800063CODE_ERROR = 0xC0DE64AUTOGEN_ERROR = 0xF00065PARSER_ERROR = 0xF00166BUILD_ERROR = 0xF00267GENFDS_ERROR = 0xF00368ECC_ERROR = 0xF00469EOT_ERROR = 0xF00570DDC_ERROR = 0xF00971WARNING_AS_ERROR = 0xF00672MIGRATION_ERROR = 0xF01073ABORT_ERROR = 0xFFFE74UNKNOWN_ERROR = 0xFFFF75## Error message of each error code76gErrorMessage = {77 FILE_NOT_FOUND : "File/directory not found in workspace",78 FILE_OPEN_FAILURE : "File open failure",79 FILE_WRITE_FAILURE : "File write failure",80 FILE_PARSE_FAILURE : "File parse failure",81 FILE_READ_FAILURE : "File read failure",82 FILE_CREATE_FAILURE : "File create failure",83 FILE_CHECKSUM_FAILURE : "Invalid checksum of file",84 FILE_COMPRESS_FAILURE : "File compress failure",85 FILE_DECOMPRESS_FAILURE : "File decompress failure",86 FILE_MOVE_FAILURE : "File move failure",87 FILE_DELETE_FAILURE : "File delete failure",88 FILE_COPY_FAILURE : "File copy failure",89 FILE_POSITIONING_FAILURE: "Failed to seeking position",90 FILE_ALREADY_EXIST : "File or directory already exists",91 FILE_TYPE_MISMATCH : "Incorrect file type",92 FILE_CASE_MISMATCH : "File name case mismatch",93 FILE_DUPLICATED : "Duplicated file found",94 FILE_UNKNOWN_ERROR : "Unknown error encountered on file",95 OPTION_UNKNOWN : "Unknown option",96 OPTION_MISSING : "Missing option",97 OPTION_CONFLICT : "Conflict options",98 OPTION_VALUE_INVALID : "Invalid value of option",99 OPTION_DEPRECATED : "Deprecated option",100 OPTION_NOT_SUPPORTED : "Unsupported option",101 OPTION_UNKNOWN_ERROR : "Unknown error when processing options",102 PARAMETER_INVALID : "Invalid parameter",103 PARAMETER_MISSING : "Missing parameter",104 PARAMETER_UNKNOWN_ERROR : "Unknown error in parameters",105 FORMAT_INVALID : "Invalid syntax/format",106 FORMAT_NOT_SUPPORTED : "Not supported syntax/format",107 FORMAT_UNKNOWN : "Unknown format",108 FORMAT_UNKNOWN_ERROR : "Unknown error in syntax/format ",109 RESOURCE_NOT_AVAILABLE : "Not available",110 RESOURCE_ALLOCATE_FAILURE : "Allocate failure",111 RESOURCE_FULL : "Full",112 RESOURCE_OVERFLOW : "Overflow",113 RESOURCE_UNDERRUN : "Underrun",114 RESOURCE_UNKNOWN_ERROR : "Unknown error",115 ATTRIBUTE_NOT_AVAILABLE : "Not available",116 ATTRIBUTE_GET_FAILURE : "Failed to retrieve",117 ATTRIBUTE_SET_FAILURE : "Failed to set",118 ATTRIBUTE_UPDATE_FAILURE: "Failed to update",119 ATTRIBUTE_ACCESS_DENIED : "Access denied",120 ATTRIBUTE_UNKNOWN_ERROR : "Unknown error when accessing",121 COMMAND_FAILURE : "Failed to execute command",122 IO_NOT_READY : "Not ready",123 IO_BUSY : "Busy",124 IO_TIMEOUT : "Timeout",125 IO_UNKNOWN_ERROR : "Unknown error in IO operation",126 UNKNOWN_ERROR : "Unknown error",127}128## Exception indicating a fatal error129class FatalError(Exception):130 pass131if __name__ == "__main__":...

Full Screen

Full Screen

test_failures_unittest.py

Source:test_failures_unittest.py Github

copy

Full Screen

1# Copyright (C) 2010 Google Inc. All rights reserved.2#3# Redistribution and use in source and binary forms, with or without4# modification, are permitted provided that the following conditions are5# met:6#7# * Redistributions of source code must retain the above copyright8# notice, this list of conditions and the following disclaimer.9# * Redistributions in binary form must reproduce the above10# copyright notice, this list of conditions and the following disclaimer11# in the documentation and/or other materials provided with the12# distribution.13# * Neither the name of Google Inc. nor the names of its14# contributors may be used to endorse or promote products derived from15# this software without specific prior written permission.16#17# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS18# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT19# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR20# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT21# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,22# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT23# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,24# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY25# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT26# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE27# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.28import webkitpy.thirdparty.unittest2 as unittest29from webkitpy.layout_tests.models.test_failures import *30class TestFailuresTest(unittest.TestCase):31 def assert_loads(self, cls):32 failure_obj = cls()33 s = failure_obj.dumps()34 new_failure_obj = TestFailure.loads(s)35 self.assertIsInstance(new_failure_obj, cls)36 self.assertEqual(failure_obj, new_failure_obj)37 # Also test that != is implemented.38 self.assertFalse(failure_obj != new_failure_obj)39 def test_unknown_failure_type(self):40 class UnknownFailure(TestFailure):41 def message(self):42 return ''43 failure_obj = UnknownFailure()44 self.assertRaises(ValueError, determine_result_type, [failure_obj])45 def test_message_is_virtual(self):46 failure_obj = TestFailure()47 self.assertRaises(NotImplementedError, failure_obj.message)48 def test_loads(self):49 for c in ALL_FAILURE_CLASSES:50 self.assert_loads(c)51 def test_equals(self):52 self.assertEqual(FailureCrash(), FailureCrash())53 self.assertNotEqual(FailureCrash(), FailureTimeout())54 crash_set = set([FailureCrash(), FailureCrash()])55 self.assertEqual(len(crash_set), 1)56 # The hash happens to be the name of the class, but sets still work:57 crash_set = set([FailureCrash(), "FailureCrash"])58 self.assertEqual(len(crash_set), 2)59 def test_crashes(self):60 self.assertEqual(FailureCrash().message(), 'content_shell crashed')...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.click('text=Get started');7 await page.click('text=Get started');8 await browser.close();9})();10const { test, expect } = require('@playwright/test');11test('test', async ({ page }) => {12 await page.click('text=Get started');13 await page.click('text=Get started');14});15const { test, expect } = require('@playwright/test');16test('test', async ({ page }) => {17 await page.click('text=Get started');18 await page.click('text=Get started');19});

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.fill('.gLFyf', 'Hello World');7 await page.keyboard.press('Enter');8 await page.waitForNavigation();9 await page.screenshot({ path: `example.png` });10 await browser.close();11})();12const { chromium } = require('playwright');13(async () => {14 const browser = await chromium.launch();15 const context = await browser.newContext();16 const page = await context.newPage();17 await page.fill('.gLFyf', 'Hello World');18 await page.keyboard.press('Enter');19 await page.waitForNavigation();20 await page.screenshot({ path: `example.png` });21 await browser.close();22})();23const { chromium } = require('playwright');24(async () => {25 const browser = await chromium.launch();26 const context = await browser.newContext();27 const page = await context.newPage();28 await page.fill('.gLFyf', 'Hello World');29 await page.keyboard.press('Enter');30 await page.waitForNavigation();31 await page.screenshot({ path: `example.png` });32 await browser.close();33})();34const { chromium } = require('playwright');35(async () => {36 const browser = await chromium.launch();37 const context = await browser.newContext();38 const page = await context.newPage();39 await page.fill('.gLFyf', 'Hello World');40 await page.keyboard.press('Enter');41 await page.waitForNavigation();42 await page.screenshot({ path: `example.png` });43 await browser.close();44})();45const { chromium } = require('playwright');46(async () => {47 const browser = await chromium.launch();48 const context = await browser.newContext();49 const page = await context.newPage();50 await page.fill('.gLFyf', '

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const page = await browser.newPage();5 await page.screenshot({ path: `example.png` });6 await browser.close();7})();8const { chromium } = require('playwright');9(async () => {10 const browser = await chromium.launch();11 const page = await browser.newPage();12 await page.screenshot({ path: `example.png` });13 await browser.close();14})();15const { chromium } = require('playwright');16(async () => {17 const browser = await chromium.launch();18 const page = await browser.newPage();19 await page.screenshot({ path: `example.png` });20 await browser.close();21})();22const { chromium } = require('playwright');23(async () => {24 const browser = await chromium.launch();25 const page = await browser.newPage();26 await page.screenshot({ path: `example.png` });27 await browser.close();28})();29const { chromium } = require('playwright');30(async () => {31 const browser = await chromium.launch();32 const page = await browser.newPage();33 await page.screenshot({ path: `example.png` });34 await browser.close();35})();36const { chromium } = require('playwright');37(async () => {38 const browser = await chromium.launch();39 const page = await browser.newPage();40 await page.screenshot({ path: `example.png` });41 await browser.close();42})();43const { chromium } =

Full Screen

Using AI Code Generation

copy

Full Screen

1import { chromium } from "playwright";2(async () => {3 const browser = await chromium.launch({ headless: false });4 const page = await browser.newPage();5 const failed = await page.failure();6 console.log(failed);7 await browser.close();8})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { test, expect } = require('@playwright/test');2test('should fail', async ({ page }) => {3 expect(page).toHaveTitle('Playwright - Google Search');4});5 Error: expect(page).toHaveTitle('Playwright - Google Search')6 at Object.<anonymous> (test.js:4:7)7 at Object.<anonymous> (test.js:1:1)8 1 passed (4s)9const { test, expect } = require('@playwright/test');10const { test, expect } = require('@playwright/test');11test.use({12 async fail({ error }) {13 await page.screenshot({ path: 'failure.png' });14 },15});16test('should fail', async ({ page }) => {17 expect(page).toHaveTitle('Playwright - Google Search');18});19 Error: expect(page).toHaveTitle('Playwright - Google Search')20 at Object.<anonymous> (test.js:11:7)21 at Object.<anonymous> (test.js:1:1)22 1 passed (4s)

Full Screen

Using AI Code Generation

copy

Full Screen

1const { _test } = require('@playwright/test');2const { expect } = require('@playwright/test');3const { test, expect } = require('@playwright/test');4test('test', async ({ page }) => {5 const title = page.locator('text="Get started"');6 await expect(title).toBeVisible();7 await _test.fail('Failure message');8 await expect(title).toBeVisible();9});

Full Screen

Using AI Code Generation

copy

Full Screen

1const { test, expect } = require('@playwright/test');2test('example', async ({ page }) => {3 const title = page.locator('text=Get started');4 await expect(title).toBeVisible();5});6const { test, expect } = require('@playwright/test');7test('example', async ({ page }) => {8 const title = page.locator('text=Get started');9 await expect(title).toBeVisible();10});11const { test, expect } = require('@playwright/test');12test('example', async ({ page }) => {13 const title = page.locator('text=Get started');14 await expect(title).toBeVisible();15});16const { test, expect } = require('@playwright/test');17test('example', async ({ page }) => {18 const title = page.locator('text=Get started');19 await expect(title).toBeVisible();20});21const { test, expect } = require('@playwright/test');22test('example', async ({ page }) => {23 const title = page.locator('text=Get started');24 await expect(title).toBeVisible();25});26const { test, expect } = require('@playwright/test');27test('example', async ({ page }) => {28 const title = page.locator('text=Get started');

Full Screen

Using AI Code Generation

copy

Full Screen

1const { failure } = require('@playwright/test/lib/reporter');2const { test } = require('@playwright/test');3test('My test', async ({ page }) => {4 try {5 } catch (error) {6 failure(error);7 }8});9const { test, expect } = require('@playwright/test');10test('My test', async ({ page }) => {11});12const { test, expect } = require('@playwright/test');13test('My test', async ({ page }) => {14});15const { test, expect } = require('@playwright/test');16test('My test', async ({ page }) => {17});18const { test, expect } = require('@playwright/test');19test('My test', async ({ page }) => {20});21const { test, expect } = require('@playwright/test');22test('My test', async ({ page }) => {23});24const { test, expect } = require('@playwright/test');25test('My test', async ({ page }) => {26});27const { test, expect } = require('@playwright/test');28test('My test', async ({ page }) => {29});30const { test, expect } = require('@playwright/test');31test('My test', async ({ page }) => {

Full Screen

Using AI Code Generation

copy

Full Screen

1const { fail } = require('@playwright/test');2fail('this is a failure');3const { test } = require('@playwright/test');4test.fail('this is a failure');5const { test, expect } = require('@playwright/test');6test('my test', async ({}) => {7 expect(true).toBe(false);8});9const { test, expect } = require('@playwright/test');10test('my test', async ({}) => {11 expect(true).toBe(false);12});

Full Screen

Using AI Code Generation

copy

Full Screen

1const { PlaywrightInternal } = require('playwright-internal');2const { Test } = PlaywrightInternal;3const test = new Test();4await test.run(async () => {5 await test.fail('Error message');6});7const { PlaywrightInternal } = require('playwright-internal');8const { Test } = PlaywrightInternal;9const test = new Test();10await test.run(async () => {11 await test.fail('Error message');12});13const { PlaywrightInternal } = require('playwright-internal');14const { Test } = PlaywrightInternal;15const test = new Test();16await test.run(async () => {17 await test.fail('Error message');18});19const { PlaywrightInternal } = require('playwright-internal');20const { Test } = PlaywrightInternal;21const test = new Test();22await test.run(async () => {23 await test.fail('Error message');24});25const { PlaywrightInternal } = require('playwright-internal');26const { Test } = PlaywrightInternal;27const test = new Test();28await test.run(async () => {29 await test.fail('Error message');30});31const { PlaywrightInternal } = require('playwright-internal');32const { Test } = PlaywrightInternal;33const test = new Test();34await test.run(async () => {35 await test.fail('Error message');36});37const { PlaywrightInternal } = require('playwright-internal');38const { Test } = PlaywrightInternal;39const test = new Test();40await test.run(async () => {41 await test.fail('Error message');42});43const { PlaywrightInternal } = require('playwright-internal');44const { Test } = PlaywrightInternal

Full Screen

Playwright tutorial

LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.

Chapters:

  1. What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
  2. How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
  3. Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
  4. What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
  5. Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
  6. Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
  7. Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
  8. Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
  9. Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
  10. Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
  11. Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
  12. Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.

Run Playwright Internal 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