def create_testcase(dt, format, expectation):
    """
    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 test ISO date formatting.
        '''

        # local time zone mock function
        def localtime_mock(self, secs):
            """
            mock time.localtime so that it always returns a time_struct with
            tm_idst=1
            """
            tt = self.ORIG['localtime'](secs)
            # befor 2000 everything is dst, after 2000 no dst.
            if tt.tm_year < 2000:
                dst = 1
            else:
                dst = 0
            tt = (tt.tm_year, tt.tm_mon, tt.tm_mday,
                  tt.tm_hour, tt.tm_min, tt.tm_sec,
                  tt.tm_wday, tt.tm_yday, dst)
            return time.struct_time(tt)

        def setUp(self):
            self.ORIG = {}
            self.ORIG['STDOFFSET'] = tzinfo.STDOFFSET
            self.ORIG['DSTOFFSET'] = tzinfo.DSTOFFSET
            self.ORIG['DSTDIFF'] = tzinfo.DSTDIFF
            self.ORIG['localtime'] = time.localtime
            # ovveride all saved values with fixtures.
            # calculate LOCAL TZ offset, so that this test runs in
            # every time zone
            tzinfo.STDOFFSET = timedelta(seconds=36000)  # assume LOC = +10:00
            tzinfo.DSTOFFSET = timedelta(seconds=39600)  # assume DST = +11:00
            tzinfo.DSTDIFF = tzinfo.DSTOFFSET - tzinfo.STDOFFSET
            time.localtime = self.localtime_mock

        def tearDown(self):
            # restore test fixtures
            tzinfo.STDOFFSET = self.ORIG['STDOFFSET']
            tzinfo.DSTOFFSET = self.ORIG['DSTOFFSET']
            tzinfo.DSTDIFF = self.ORIG['DSTDIFF']
            time.localtime = self.ORIG['localtime']

        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,
                                  strftime(dt, format))
            else:
                self.assertEqual(strftime(dt, format),
                                 expectation)

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