def create_testcase(datetimestring, expectation, format, output):
    """
    Create a TestCase class for a specific test.

    This allows having a separate TestCase for each test tuple from the
    TEST_CASES list, so that a failed test won't stop other tests.
    """

    class TestDateTime(unittest.TestCase):
        '''
        A test case template to parse an ISO datetime string into a
        datetime object.
        '''

        def test_parse(self):
            '''
            Parse an ISO datetime string and compare it to the expected value.
            '''
            if expectation is None:
                self.assertRaises(ISO8601Error, parse_datetime, datetimestring)
            else:
                self.assertEqual(parse_datetime(datetimestring), expectation)

        def test_format(self):
            '''
            Take datetime object and create ISO string from it.
            This is the reverse test to test_parse.
            '''
            if expectation is None:
                self.assertRaises(AttributeError,
                                  datetime_isoformat, expectation, format)
            else:
                self.assertEqual(datetime_isoformat(expectation, format),
                                 output)

    return unittest.TestLoader().loadTestsFromTestCase(TestDateTime)

    Create a TestCase class for a specific test.

    This allows having a separate TestCase for each test tuple from the
    TEST_CASES list, so that a failed test won't stop other tests.
    
Solutions/CyberArkAudit/Data Connectors/.python_packages/lib/site-packages/isodate/tests/test_datetime.py