Debian Codegraph @

test/example/check-example

raw
1 #!/usr/bin/python3 -cimport os, sys; os.execv(os.path.dirname(sys.argv[1]) + "/../common/pywrap", sys.argv)
2
3 #
4 # Copyright (C) 2013 Red Hat, Inc.
5 # SPDX-License-Identifier: LGPL-2.1-or-later
6
7
8 import os
9 import sys
10 import time
11 import unittest
12
13 import testlib
14
15
16 class TestExample(testlib.MachineCase):
17
18 @unittest.expectedFailure
19 def testExpectedFail(self):
20 self.login_and_go("/system")
21 self.assertFalse(True) # ruff: ignore[boolean-positional-value-in-call]
22
23 def testFail(self):
24 self.login_and_go("/system")
25 if os.environ.get('TEST_FAILURES'):
26 self.assertFalse(True) # ruff: ignore[boolean-positional-value-in-call]
27
28 @unittest.skip('not supported')
29 def testSkip(self):
30 self.login_and_go("/system")
31 self.assertFalse(True) # ruff: ignore[boolean-positional-value-in-call]
32
33 def testRaiseSkip(self):
34 raise unittest.SkipTest("dynamic skip")
35
36 @testlib.nondestructive
37 def testNondestructive(self):
38 self.login_and_go("/system")
39
40 def testBasic(self):
41 self.login_and_go("/system")
42
43
44 @testlib.nondestructive
45 class TestNondestructiveExample(testlib.MachineCase):
46
47 def testOne(self):
48 self.assertEqual(self.machine.execute("whoami").strip(), "root")
49
50 def testTwo(self):
51 self.assertIn("usr", self.machine.execute("ls -l /").strip())
52
53
54 class TestSimple(unittest.TestCase):
55
56 def testOne(self):
57 for i in range(10):
58 time.sleep(0.100)
59 if i % 2:
60 sys.stderr.write(">1%i\n" % i)
61 else:
62 print(">2", i)
63 self.assertTrue(True) # ruff: ignore[boolean-positional-value-in-call]
64
65 @unittest.expectedFailure
66 def testTwo(self):
67 self.assertFalse(True) # ruff: ignore[boolean-positional-value-in-call]
68
69 def testThree(self):
70 self.assertTrue(True) # ruff: ignore[boolean-positional-value-in-call]
71
72
73 class TestTodo(unittest.TestCase):
74 def setUp(self):
75 if not os.environ.get('TEST_TODO'):
76 self.skipTest('not testing TestTodo')
77
78 @testlib.todo('2 is not yet sufficiently large')
79 def testTodoFail(self):
80 assert 2 + 2 == 5
81
82 @testlib.todo('2 is not yet sufficiently large')
83 def testTodoPass(self):
84 assert 2 + 2 == 4
85
86
87 if __name__ == '__main__':
88 testlib.test_main()