Ejemplo n.º 1
0
 def test_SoftAssertIsTrueTestFailure(self):
     with self.assertRaises(AttributeError):
         soft_assert = SoftAssert(
             FileLogger(LoggingConfig.get_log_directory(),
                        "UnitTests.SoftAssertUnitTests.SoftAssertFailTest",
                        MessageType.GENERIC.name, True))
         soft_assert.assertTrue(1 == 2, "Test")
         soft_assert.assertTrue(1 == 2, "Test1")
         soft_assert.assertTrue(True, "Test2")
         soft_assert.fail_test_if_assert_failed()
Ejemplo n.º 2
0
    def test_SoftAssertVerifyCheckForFailures(self):
        soft_assert = SoftAssert(
            FileLogger(
                LoggingConfig.get_log_directory(),
                "UnitTests.SoftAssertUnitTests.SoftAssertVerifyCheckForFailures"
            ))
        soft_assert.assertEquals("Yes", "Yes", "Utilities Soft Assert",
                                 "Message is not equal")

        soft_assert.fail_test_if_assert_failed()
        self.assertTrue(soft_assert.did_user_check())

        soft_assert.assertEquals("Yes", "Yes", "Utilities Soft Assert",
                                 "Message is not equal")
        self.assertFalse(soft_assert.did_user_check())
Ejemplo n.º 3
0
 def test_SoftAssertValidTest():
     soft_assert = SoftAssert(
         FileLogger(LoggingConfig.get_log_directory(),
                    "UnitTests.SoftAssertUnitTests.SoftAssertValidTest"))
     soft_assert.assertEquals("Yes", "Yes", "Utilities Soft Assert",
                              "Message is not equal")
     soft_assert.assertEquals("YesAgain", "YesAgain",
                              "Utilities Soft Assert 2")
     soft_assert.fail_test_if_assert_failed()
Ejemplo n.º 4
0
 def test_SoftAssertFailTest(self):
     with self.assertRaises(AttributeError):
         soft_assert = SoftAssert(
             FileLogger(LoggingConfig.get_log_directory(),
                        "UnitTests.SoftAssertUnitTests.SoftAssertFailTest"))
         soft_assert.assertEquals("Yes", "No", "Utilities Soft Assert",
                                  "Message is not equal")
         soft_assert.assertEquals("Yes", "NoAgain",
                                  "Utilities Soft Assert 2")
         soft_assert.fail_test_if_assert_failed()
Ejemplo n.º 5
0
    def test_SoftAssertDidFailCheck(self):
        soft_assert = SoftAssert(
            FileLogger(LoggingConfig.get_log_directory(),
                       "UnitTests.SoftAssertUnitTests.SoftAssertIsTrueTest",
                       MessageType.GENERIC.name, True))
        soft_assert.assertTrue(True, "Test1")
        self.assertFalse(soft_assert.did_soft_asserts_fail())

        soft_assert.assertTrue(1 == 2, "Test2")
        self.assertTrue(soft_assert.did_soft_asserts_fail())
Ejemplo n.º 6
0
 def test_SoftAssertIsFalseTest():
     soft_assert = SoftAssert(
         FileLogger(LoggingConfig.get_log_directory(),
                    "UnitTests.SoftAssertUnitTests.SoftAssertIsFalseTest",
                    MessageType.GENERIC.value, True))
     soft_assert.assertFalse(2 == 1, "Test")
     soft_assert.fail_test_if_assert_failed()
Ejemplo n.º 7
0
    def test_SoftAssertFailsValidTest(self):
        soft_assert = SoftAssert(
            FileLogger(
                LoggingConfig.get_log_directory(),
                "UnitTests.SoftAssertUnitTests.SoftAssertFailsValidTest"))
        soft_assert.fails(
            lambda x: self.MethodThrowsNoneException(), TypeError,
            "Assert Method Throws Explicit Exception",
            "Failed to assert that method threw a NullReferenceException")
        result = 9 / 0
        soft_assert.fails(
            self.fail(
                f"Result should have thrown an error but is {result} instead"),
            # soft_assert.assertFails(lambda x: (result = 9 / 0) self.fail(f"Result should have thrown
            # an error but is {result} instead"),
            ZeroDivisionError,
            "Assert  action throws divide by zero exception",
            "Failed to assert that we couldn't divide by zero")

        soft_assert.fail_test_if_assert_failed()
Ejemplo n.º 8
0
 def test_SoftAssertFailsInvalidTest(self):
     with self.assertRaises(AttributeError):
         soft_assert = SoftAssert(
             FileLogger(
                 LoggingConfig.get_log_directory(),
                 "UnitTests.SoftAssertUnitTests.SoftAssertFailsInvalidTest")
         )
         soft_assert.fails(
             lambda x: self.MethodThrowsNoneException(),
             NotImplementedError, "Assert Method Throws Explicit Exception",
             "Failed to assert that method threw a NotImplementedException")
         result = 9 / 0
         soft_assert.fails(
             self.fail(
                 f"Result should have thrown an error but is {result} instead"
             ),
             # soft_assert.assertFails(lambda x: (result = 9 / 0) self.fail(f"Result should have
             # thrown an error but is {result} instead"),
             TypeError,
             "Assert  dividing by zero throws a null reference",
             "Failed to assert that we couldn't divide by zero")
         soft_assert.fail_test_if_assert_failed()
Ejemplo n.º 9
0
 def test_SoftAssertVerifyUserCheck(self):
     soft_assert = SoftAssert(
         FileLogger(
             LoggingConfig.get_log_directory(),
             "UnitTests.SoftAssertUnitTests.SoftAssertVerifyUserCheck"))
     self.assertTrue(soft_assert.did_user_check())