def create_testcase(yeardigits, datestring, expectation, format):
    '''
    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 TestDate(unittest.TestCase):
        '''
        A test case template to parse an ISO date string into a date
        object.
        '''

        def test_parse(self):
            '''
            Parse an ISO date string and compare it to the expected value.
            '''
            if expectation is None:
                self.assertRaises(ISO8601Error, parse_date, datestring,
                                  yeardigits)
            else:
                result = parse_date(datestring, yeardigits)
                self.assertEqual(result, expectation)

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

    return unittest.TestLoader().loadTestsFromTestCase(TestDate)

    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_date.py