def test_function_source_signature(self):

    def good_fn(split, shuffle_files):
        del split
        del shuffle_files
    dataset_providers.FunctionDataSource(good_fn, splits=('train',))

    def default_good_fn(split, shuffle_files=False):
        del split
        del shuffle_files
    dataset_providers.FunctionDataSource(default_good_fn, splits=('train',))

    def seed_fn(split, shuffle_files=True, seed=0):
        del split
        del shuffle_files
        del seed
    dataset_providers.FunctionDataSource(seed_fn, splits=('train',))

    def extra_kwarg_good_fn(split, shuffle_files, unused_kwarg=True):
        del split
        del shuffle_files
    dataset_providers.FunctionDataSource(extra_kwarg_good_fn, splits=('train',))
    with self.assertRaisesWithLiteralMatch(ValueError, "'missing_shuff' must have positional args ('split', 'shuffle_files'), got: ('split',)"):

        def missing_shuff(split):
            del split
        dataset_providers.FunctionDataSource(missing_shuff, splits=('train',))
    with self.assertRaisesWithLiteralMatch(ValueError, "'missing_split' must have positional args ('split', 'shuffle_files'), got: ('shuffle_files',)"):

        def missing_split(shuffle_files):
            del shuffle_files
        dataset_providers.FunctionDataSource(missing_split, splits=('train',))
    with self.assertRaisesWithLiteralMatch(ValueError, "'extra_pos_arg' may only have positional args ('split', 'shuffle_files'), got: ('split', 'shuffle_files', 'unused_arg')"):

        def extra_pos_arg(split, shuffle_files, unused_arg):
            del split
            del shuffle_files
        dataset_providers.FunctionDataSource(extra_pos_arg, splits=('train',))
def test_function_source_signature(self):

    def good_fn(split, shuffle_files):
        del split
        del shuffle_files
    dataset_providers.FunctionDataSource(good_fn, splits=('train',))

    def default_good_fn(split, shuffle_files=False):
        del split
        del shuffle_files
    dataset_providers.FunctionDataSource(default_good_fn, splits=('train',))

    def seed_fn(split, shuffle_files=True, seed=0):
        del split
        del shuffle_files
        del seed
    dataset_providers.FunctionDataSource(seed_fn, splits=('train',))

    def extra_kwarg_good_fn(split, shuffle_files, unused_kwarg=True):
        del split
        del shuffle_files
    dataset_providers.FunctionDataSource(extra_kwarg_good_fn, splits=('train',))
    with self.assertRaisesWithLiteralMatch(ValueError, "'missing_shuff' must have positional args ('split', 'shuffle_files'), got: ('split',)"):

        def missing_shuff(split):
            del split
        dataset_providers.FunctionDataSource(missing_shuff, splits=('train',))
    with self.assertRaisesWithLiteralMatch(ValueError, "'missing_split' must have positional args ('split', 'shuffle_files'), got: ('shuffle_files',)"):

        def missing_split(shuffle_files):
            del shuffle_files
        dataset_providers.FunctionDataSource(missing_split, splits=('train',))
    with self.assertRaisesWithLiteralMatch(ValueError, "'extra_pos_arg' may only have positional args ('split', 'shuffle_files'), got: ('split', 'shuffle_files', 'unused_arg')"):

        def extra_pos_arg(split, shuffle_files, unused_arg):
            del split
            del shuffle_files
        dataset_providers.FunctionDataSource(extra_pos_arg, splits=('train',))