コード例 #1
0
 def ten_alphanum_characters_when_length_is_specified_test(self):
     test_pattern = self.alphanum_pattern + self.repeat_ten_times
     test_gen = ReGenerator(test_pattern)
     result = test_gen.generate()
     self.assertEqual(len(result), 10)
     self.assertRegexpMatches(result, self.alphanum_pattern)
     self.assertRegexpMatches(result, self.alphanum_short_pattern)
コード例 #2
0
 def question_mark_as_repeat_once_pattern_test(self):
     test_pattern = self.alternatives + self.repeat_once_question_mark
     equivalent_pattern = self.alternatives + '{2}'
     test_gen = ReGenerator(test_pattern)
     result = test_gen.generate()
     self.assertRegexpMatches(result, equivalent_pattern)
     self.assertEqual(len(result), 2 * 3)
コード例 #3
0
 def question_mark_as_repeat_once_pattern_test(self):
     test_pattern = self.alternatives + self.repeat_once_question_mark
     equivalent_pattern = self.alternatives + '{2}'
     test_gen = ReGenerator(test_pattern)
     result = test_gen.generate()
     self.assertRegexpMatches(result, equivalent_pattern)
     self.assertEqual(len(result), 2 * 3)
コード例 #4
0
 def alphanum_character_when_repeated_once_test(self):
     test_pattern = self.alphanum_pattern + self.repeat_once
     test_gen = ReGenerator(test_pattern)
     result = test_gen.generate()
     self.assertEqual(len(result), 1)
     self.assertRegexpMatches(result, self.alphanum_pattern)
     self.assertRegexpMatches(result, self.alphanum_short_pattern)
コード例 #5
0
 def alphanum_character_when_repeated_once_test(self):
     test_pattern = self.alphanum_pattern + self.repeat_once
     test_gen = ReGenerator(test_pattern)
     result = test_gen.generate()
     self.assertEqual(len(result), 1)
     self.assertRegexpMatches(result, self.alphanum_pattern)
     self.assertRegexpMatches(result, self.alphanum_short_pattern)
コード例 #6
0
 def ten_alphanum_characters_when_length_is_specified_test(self):
     test_pattern = self.alphanum_pattern + self.repeat_ten_times
     test_gen = ReGenerator(test_pattern)
     result = test_gen.generate()
     self.assertEqual(len(result), 10)
     self.assertRegexpMatches(result, self.alphanum_pattern)
     self.assertRegexpMatches(result, self.alphanum_short_pattern)
コード例 #7
0
 def variable_string_length_with_alpha_characters_test(self):
     test_pattern = self.alpha_pattern + self.repeat_nine_to_ten_times
     test_gen = ReGenerator(test_pattern)
     result = test_gen.generate()
     self.assertGreaterEqual(len(result), 9)
     self.assertLessEqual(len(result), 10)
     self.assertRegexpMatches(result, self.alpha_pattern)
     self.assertNotRegexpMatches(result, self.num_pattern)
コード例 #8
0
 def variable_string_length_with_alpha_characters_test(self):
     test_pattern = self.alpha_pattern + self.repeat_nine_to_ten_times
     test_gen = ReGenerator(test_pattern)
     result = test_gen.generate()
     self.assertGreaterEqual(len(result), 9)
     self.assertLessEqual(len(result), 10)
     self.assertRegexpMatches(result, self.alpha_pattern)
     self.assertNotRegexpMatches(result, self.num_pattern)
コード例 #9
0
 def short_num_character_repeated_ten_times_test(self):
     test_pattern = self.numbers_short_pattern + self.repeat_ten_times
     equivalent_pattern = self.num_pattern + self.repeat_ten_times
     test_gen = ReGenerator(test_pattern)
     result = test_gen.generate()
     self.assertEqual(len(result), 10)
     self.assertRegexpMatches(result, test_pattern)
     self.assertRegexpMatches(result, equivalent_pattern)
コード例 #10
0
 def short_num_character_repeated_ten_times_test(self):
     test_pattern = self.numbers_short_pattern + self.repeat_ten_times
     equivalent_pattern = self.num_pattern + self.repeat_ten_times
     test_gen = ReGenerator(test_pattern)
     result = test_gen.generate()
     self.assertEqual(len(result), 10)
     self.assertRegexpMatches(result, test_pattern)
     self.assertRegexpMatches(result, equivalent_pattern)
コード例 #11
0
 def listerals_and_patterns_test(self):
     literal = 'test_literal'
     pattern = '[a-zA-Z0-9]{3}'
     test_pattern = literal + pattern
     test_gen = ReGenerator(test_pattern)
     result = test_gen.generate()
     self.assertEqual(len(result), 15)
     self.assertEqual(result[:12], literal)
     self.assertRegexpMatches(result[-3:], pattern)
コード例 #12
0
 def listerals_and_patterns_test(self):
     literal = 'test_literal'
     pattern = '[a-zA-Z0-9]{3}'
     test_pattern = literal + pattern
     test_gen = ReGenerator(test_pattern)
     result = test_gen.generate()
     self.assertEqual(len(result), 15)
     self.assertEqual(result[:12], literal)
     self.assertRegexpMatches(result[-3:], pattern)
コード例 #13
0
 def unsupported_macro_character(self):
     test_gen = ReGenerator(self.tabular_as_unsupported_character)
     with self.assertRaises(ParseFatalException):
         test_gen.generate()
コード例 #14
0
 def alternative_from_characters_sequence_test(self):
     test_pattern = '([A-Z]{2}|[a-z]{2}|\d{2})'
     test_gen = ReGenerator(test_pattern)
     result = test_gen.generate()
     self.assertRegexpMatches(result, test_pattern)
     self.assertEqual(len(result), 2)
コード例 #15
0
 def unbounded_repetition_pattern_test(self):
     test_pattern = self.alpha_pattern + self.unbounded_repetition_pattern
     test_gen = ReGenerator(test_pattern)
     with self.assertRaises(ParseFatalException):
         test_gen.generate()
コード例 #16
0
 def unbounded_repetition_pattern_test(self):
     test_pattern = self.alpha_pattern + self.unbounded_repetition_pattern
     test_gen = ReGenerator(test_pattern)
     with self.assertRaises(ParseFatalException):
         test_gen.generate()
コード例 #17
0
 def dot_as_pattern_test(self):
     test_pattern = '.'
     test_gen = ReGenerator(test_pattern)
     result = test_gen.generate()
     self.assertRegexpMatches(result, '.')
コード例 #18
0
 def space_short_pattern_test(self):
     test_gen = ReGenerator(self.space_short_pattern)
     result = test_gen.generate()
     self.assertEqual(len(result), 1)
     self.assertRegexpMatches(result, self.space_short_pattern)
     self.assertRegexpMatches(result, ' ')
コード例 #19
0
 def space_short_pattern_test(self):
     test_gen = ReGenerator(self.space_short_pattern)
     result = test_gen.generate()
     self.assertEqual(len(result), 1)
     self.assertRegexpMatches(result, self.space_short_pattern)
     self.assertRegexpMatches(result, ' ')
コード例 #20
0
 def alternative_from_characters_sequence_test(self):
     test_pattern = '([A-Z]{2}|[a-z]{2}|\d{2})'
     test_gen = ReGenerator(test_pattern)
     result = test_gen.generate()
     self.assertRegexpMatches(result, test_pattern)
     self.assertEqual(len(result), 2)
コード例 #21
0
 def unsupported_macro_character(self):
     test_gen = ReGenerator(self.tabular_as_unsupported_character)
     with self.assertRaises(ParseFatalException):
         test_gen.generate()
コード例 #22
0
 def short_num_character_without_repeatition_test(self):
     test_gen = ReGenerator(self.numbers_short_pattern)
     result = test_gen.generate()
     self.assertEqual(len(result), 1)
     self.assertRegexpMatches(result, self.numbers_short_pattern)
     self.assertRegexpMatches(result, self.num_pattern)
コード例 #23
0
 def only_one_alphanum_shorthand_test(self):
     test_gen = ReGenerator(self.alphanum_short_pattern)
     result = test_gen.generate()
     self.assertEqual(len(result), 1)
     self.assertRegexpMatches(result, self.alphanum_pattern)
     self.assertRegexpMatches(result, self.alphanum_short_pattern)
コード例 #24
0
 def listerals_characters_test(self):
     test_pattern = 'test_literal'
     test_gen = ReGenerator(test_pattern)
     result = test_gen.generate()
     self.assertEqual(result, test_pattern)
コード例 #25
0
 def short_num_character_without_repeatition_test(self):
     test_gen = ReGenerator(self.numbers_short_pattern)
     result = test_gen.generate()
     self.assertEqual(len(result), 1)
     self.assertRegexpMatches(result, self.numbers_short_pattern)
     self.assertRegexpMatches(result, self.num_pattern)
コード例 #26
0
 def empty_pattern_test(self):
     with self.assertRaises(ValueError):
         ReGenerator("")
コード例 #27
0
 def only_one_alphanum_shorthand_test(self):
     test_gen = ReGenerator(self.alphanum_short_pattern)
     result = test_gen.generate()
     self.assertEqual(len(result), 1)
     self.assertRegexpMatches(result, self.alphanum_pattern)
     self.assertRegexpMatches(result, self.alphanum_short_pattern)
コード例 #28
0
 def string_reprezentation_of_pgenerator_test(self):
     test_pattern = self.alternatives + self.repeat_ten_times
     test_gen = ReGenerator(test_pattern)
     self.assertEqual(str(test_gen), "pattern: %s\n" % (test_pattern))
     self.assertEqual(repr(test_gen), "pattern: %s\n" % (test_pattern))
コード例 #29
0
 def three_characters_alternatives_repeated_ten_times(self):
     test_pattern = self.alternatives + self.repeat_ten_times
     test_gen = ReGenerator(test_pattern)
     result = test_gen.generate()
     self.assertEqual(len(result), 3 * 10)
     self.assertRegexpMatches(result, test_pattern)
コード例 #30
0
 def dot_as_pattern_test(self):
     test_pattern = '.'
     test_gen = ReGenerator(test_pattern)
     result = test_gen.generate()
     self.assertRegexpMatches(result, '.')
コード例 #31
0
 def three_characters_alternatives_without_repetitions_test(self):
     test_gen = ReGenerator(self.alternatives)
     result = test_gen.generate()
     self.assertEqual(len(result), 3)
     self.assertRegexpMatches(result, self.alternatives)
コード例 #32
0
 def listerals_characters_test(self):
     test_pattern = 'test_literal'
     test_gen = ReGenerator(test_pattern)
     result = test_gen.generate()
     self.assertEqual(result, test_pattern)
コード例 #33
0
 def three_characters_alternatives_without_repetitions_test(self):
     test_gen = ReGenerator(self.alternatives)
     result = test_gen.generate()
     self.assertEqual(len(result), 3)
     self.assertRegexpMatches(result, self.alternatives)
コード例 #34
0
 def three_characters_alternatives_repeated_ten_times(self):
     test_pattern = self.alternatives + self.repeat_ten_times
     test_gen = ReGenerator(test_pattern)
     result = test_gen.generate()
     self.assertEqual(len(result), 3 * 10)
     self.assertRegexpMatches(result, test_pattern)