#!/usr/bin/python3 -cimport os, sys; os.execv(os.path.dirname(sys.argv[1]) + "/../common/pywrap", sys.argv) # # Copyright (C) 2013 Red Hat, Inc. # SPDX-License-Identifier: LGPL-2.1-or-later import os import sys import time import unittest import testlib class TestExample(testlib.MachineCase): @unittest.expectedFailure def testExpectedFail(self): self.login_and_go("/system") self.assertFalse(True) # ruff: ignore[boolean-positional-value-in-call] def testFail(self): self.login_and_go("/system") if os.environ.get('TEST_FAILURES'): self.assertFalse(True) # ruff: ignore[boolean-positional-value-in-call] @unittest.skip('not supported') def testSkip(self): self.login_and_go("/system") self.assertFalse(True) # ruff: ignore[boolean-positional-value-in-call] def testRaiseSkip(self): raise unittest.SkipTest("dynamic skip") @testlib.nondestructive def testNondestructive(self): self.login_and_go("/system") def testBasic(self): self.login_and_go("/system") @testlib.nondestructive class TestNondestructiveExample(testlib.MachineCase): def testOne(self): self.assertEqual(self.machine.execute("whoami").strip(), "root") def testTwo(self): self.assertIn("usr", self.machine.execute("ls -l /").strip()) class TestSimple(unittest.TestCase): def testOne(self): for i in range(10): time.sleep(0.100) if i % 2: sys.stderr.write(">1%i\n" % i) else: print(">2", i) self.assertTrue(True) # ruff: ignore[boolean-positional-value-in-call] @unittest.expectedFailure def testTwo(self): self.assertFalse(True) # ruff: ignore[boolean-positional-value-in-call] def testThree(self): self.assertTrue(True) # ruff: ignore[boolean-positional-value-in-call] class TestTodo(unittest.TestCase): def setUp(self): if not os.environ.get('TEST_TODO'): self.skipTest('not testing TestTodo') @testlib.todo('2 is not yet sufficiently large') def testTodoFail(self): assert 2 + 2 == 5 @testlib.todo('2 is not yet sufficiently large') def testTodoPass(self): assert 2 + 2 == 4 if __name__ == '__main__': testlib.test_main()