def __new__(mcs, name, bases, d):
        """
        This method overrides default behaviour for creation of new instances. For every directory abc in data it
        creates a method called test_abc, with the body of load_and_compare function.
        """
        def gen_test(suite_name):
            def load_and_compare(self):
                # load the context.pkl, document.pmml and estimator.pkl
                suite_path = os.path.join(mcs.DATA_DIR, suite_name)
                content = os.listdir(suite_path)
                assert len(content) == 3, 'There should be exactly two files in the suite directory'
                assert mcs.ESTIMATOR_FILE_NAME in content, 'Estimator should be stored in {} file'.format(mcs.ESTIMATOR_FILE_NAME)
                assert content in mcs.PMML_FILE_NAME, 'PMML should be stored in {} file'.format(mcs.PMML_FILE_NAME)
                assert mcs.CONTEXT_FILE_NAME in content, 'Context should be stored in {} file'.format(mcs.CONTEXT_FILE_NAME)
                with open(os.path.join(suite_path, mcs.ESTIMATOR_FILE_NAME), 'r') as est_file:
                    est = pickle.load(est_file)
                    assert isinstance(est, BaseEstimator), '{} should be a trained estimator'.format(mcs.ESTIMATOR_FILE_NAME)
                with open(os.path.join(suite_path, mcs.CONTEXT_FILE_NAME), 'r') as ctx_file:
                    ctx = pickle.load(ctx_file)
                    assert isinstance(ctx, TransformationContext), '{} should be a transformation context'.format(mcs.CONTEXT_FILE_NAME)
                converter = find_converter(est)
                assert converter is not None, 'Can not find converter for {}'.format(est)
                transformed_pmml = converter(est, ctx).pmml()
                with open(os.path.join(suite_path, mcs.PMML_FILE_NAME), 'r') as pmml_file:
                    loaded_pmml = pmml.CreateFromDocument('\n'.join(pmml_file.readlines()))
                self.maxDiff = None
                # make sure that the expected PMML matches the produced one
                self.assertEquals(loaded_pmml.toDOM().toprettyxml(), transformed_pmml.toDOM().toprettyxml())

            return load_and_compare

        # for every batch in the data dir create a corresponding test method
        for case in os.listdir(TestSerializationMeta.DATA_DIR):
            test_name = 'test_{}'.format(case)
            d[test_name] = gen_test(case)
        return type.__new__(mcs, name, bases, d)
dataset/ETHPy150Open alex-pirozhenko/sklearn-pmml/sklearn_pmml/test/__init__.py/TestSerializationMeta.__new__/swapped operands of `in`