return x % 2 == 0 self.calls = [] self._DefineFlagAndValidators(Required, Even) self.assertEqual(['Required', 'Even'], self.calls) self.calls = [] self._DefineFlagAndValidators(Even, Required) self.assertEqual(['Even', 'Required'], self.calls) def _DefineFlagAndValidators(self, first_validator, second_validator): local_flags = gflags.FlagValues() gflags.DEFINE_integer('test_flag', 2, 'test flag', flag_values=local_flags) gflags.RegisterValidator('test_flag', first_validator, message='', flag_values=local_flags) gflags.RegisterValidator('test_flag', second_validator, message='', flag_values=local_flags) argv = ('./program') local_flags(argv) if __name__ == '__main__': googletest.main()
def Even(x): self.calls.append('Even') return x % 2 == 0 self.calls = [] self._DefineFlagAndValidators(Required, Even) self.assertEquals(['Required', 'Even'], self.calls) self.calls = [] self._DefineFlagAndValidators(Even, Required) self.assertEquals(['Even', 'Required'], self.calls) def _DefineFlagAndValidators(self, first_validator, second_validator): local_flags = gflags.FlagValues() gflags.DEFINE_integer('test_flag', 2, 'test flag', flag_values=local_flags) gflags.RegisterValidator('test_flag', first_validator, message='', flag_values=local_flags) gflags.RegisterValidator('test_flag', second_validator, message='', flag_values=local_flags) argv = ('./program') local_flags(argv) if __name__ == '__main__': googletest.main()