コード例 #1
0
 def test_name_regenerate(self):
     for i in range(1, 5):
         with self.subTest(i=i):
             res = generators.generate(
                 ["name_regenerate", "Very Secret Name"])
             self.assertRegex(res,
                              '[A-Z][a-z]{3} [A-Z][a-z]{5} [A-Z][a-z]{3}')
コード例 #2
0
 def test_namelike(self):
     for i in range(1, 5):
         with self.subTest(i=i):
             res = generators.generate(["namelike"])
             self.assertRegex(res, '[A-Z][a-z]* [A-Z][a-z]*')
             self.assertGreater(len(res), 10)
             self.assertLess(len(res), 22)
コード例 #3
0
 def test_numeric_range(self):
     for i in range(1, 10):
         with self.subTest(i=i):
             res = generators.generate(
                 ["num", "--min", "123", "--max", "40000"])
             self.assertTrue(res.isnumeric())
             self.assertGreaterEqual(int(res), 123)
             self.assertLessEqual(int(res), 40000)
コード例 #4
0
 def get_next(self, elem) -> str:
     if self.sd.policy == SubstGenPolicy.CACHED and elem.text in self.cache:
         return self.cache[elem.text]
     else:
         gen_value = self.sd.gen_value
         gen_params = gen_value.split()
         final_gen_params = list(map(lambda par: _escape_special_params(elem, par), gen_params))
         new_value = generators.generate(final_gen_params)
         self.cache[elem.text] = new_value
         return new_value
コード例 #5
0
 def test_numeric_length(self):
     res = generators.generate(["num", "-l", "13"])
     self.assertEqual(len(res), 13)
     self.assertTrue(res.isnumeric())
コード例 #6
0
 def test_alphanum(self):
     res = generators.generate(["alphanum", "-l", "13"])
     self.assertEqual(len(res), 13)
     self.assertTrue(res.isalnum())
コード例 #7
0
 def test_const(self):
     self.assertEqual(generators.generate(["const", "foo"]), "foo")