forked from openwisp/openwisp-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_selenium_mixin.py
More file actions
71 lines (56 loc) · 2.19 KB
/
test_selenium_mixin.py
File metadata and controls
71 lines (56 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
from unittest import TestResult, TestSuite, skip
from django.test import SimpleTestCase
from django.test.runner import RemoteTestRunner
from openwisp_utils.tests.selenium import SeleniumTestMixin
class TestSeleniumMixinSkipHandling(SimpleTestCase):
def _run_skipped_standard_test(self):
class SkippedSeleniumTest(SeleniumTestMixin, SimpleTestCase):
retry_max = 0
retry_delay = 0
@skip("skip propagation regression test")
def test_skip(self):
pass
test = SkippedSeleniumTest("test_skip")
result = TestResult()
test._setup_and_call(result)
return result
def _run_skipped_remote_suite(self):
class DummyWebDriver:
def quit(self):
pass
class SkippedSeleniumTest(SeleniumTestMixin, SimpleTestCase):
retry_max = 0
retry_delay = 0
@classmethod
def get_webdriver(cls):
return DummyWebDriver()
@skip("first skip propagation regression test")
def test_first_skip(self):
pass
@skip("second skip propagation regression test")
def test_second_skip(self):
pass
suite = TestSuite(
[
SkippedSeleniumTest("test_first_skip"),
SkippedSeleniumTest("test_second_skip"),
]
)
return RemoteTestRunner().run(suite)
def test_setup_and_call_propagates_skip_to_standard_result(self):
result = self._run_skipped_standard_test()
self.assertEqual(len(result.skipped), 1)
self.assertEqual(result.skipped[0][1], "skip propagation regression test")
def test_setup_and_call_preserves_remote_skip_events_for_multiple_tests(self):
result = self._run_skipped_remote_suite()
self.assertEqual(
result.events,
[
("startTest", 0),
("addSkip", 0, "first skip propagation regression test"),
("stopTest", 0),
("startTest", 1),
("addSkip", 1, "second skip propagation regression test"),
("stopTest", 1),
],
)