예제 #1
0
    def test_generations(self):
        fg = FuzzyGenerator("$range(2)$ dnd$'as'$", "pp")
        self.assertEqual(list(fg.generate()), [
            ('0 dnda', 'pp'), ('0 dnds', 'pp'),
            ('1 dnda', 'pp'), ('1 dnds', 'pp')])

        fg = FuzzyGenerator("$range(2)$ d$'as'$", "p$string.lowercase[:2]$")
        self.assertEqual(list(fg.generate()), [
            ('0 da', 'pa'), ('0 da', 'pb'), ('0 ds', 'pa'), ('0 ds', 'pb'),
            ('1 da', 'pa'), ('1 da', 'pb'), ('1 ds', 'pa'), ('1 ds', 'pb'),
        ])
예제 #2
0
 def test_inside_doubledollar(self):
     fg = FuzzyGenerator(
         "GET http://localhost/$['aaa\$b', 'b\$ccc']$ HTTP/1.0", "")
     self.assertEqual(list(fg.generate()), [
         ("GET http://localhost/aaa$b HTTP/1.0", ""),
         ("GET http://localhost/b$ccc HTTP/1.0", ""),
     ])
예제 #3
0
 def test_inside_doubledollar(self):
     fg = FuzzyGenerator(
         "GET http://localhost/$['aaa\$b', 'b\$ccc']$ HTTP/1.0", "")
     self.assertEqual(list(fg.generate()), [
         ("GET http://localhost/aaa$b HTTP/1.0", ""),
         ("GET http://localhost/b$ccc HTTP/1.0", ""),
     ])
예제 #4
0
    def test_quant_gen_gen(self):
        fg = FuzzyGenerator("$range(2)$ dnd$'as'$", "pp")
        self.assertEqual(fg.calculate_quantity(), 4)

        self.assertEqual(list(fg.generate()), [
            ('0 dnda', 'pp'), ('0 dnds', 'pp'),
            ('1 dnda', 'pp'), ('1 dnds', 'pp')])
예제 #5
0
    def test_quant_gen_gen(self):
        fg = FuzzyGenerator("$range(2)$ dnd$'as'$", "pp")
        self.assertEqual(fg.calculate_quantity(), 4)

        self.assertEqual(list(fg.generate()), [('0 dnda', 'pp'),
                                               ('0 dnds', 'pp'),
                                               ('1 dnda', 'pp'),
                                               ('1 dnds', 'pp')])
예제 #6
0
    def test_generations(self):
        fg = FuzzyGenerator("$range(2)$ dnd$'as'$", "pp")
        self.assertEqual(list(fg.generate()), [('0 dnda', 'pp'),
                                               ('0 dnds', 'pp'),
                                               ('1 dnda', 'pp'),
                                               ('1 dnds', 'pp')])

        fg = FuzzyGenerator("$range(2)$ d$'as'$", "p$string.lowercase[:2]$")
        self.assertEqual(list(fg.generate()), [
            ('0 da', 'pa'),
            ('0 da', 'pb'),
            ('0 ds', 'pa'),
            ('0 ds', 'pb'),
            ('1 da', 'pa'),
            ('1 da', 'pb'),
            ('1 ds', 'pa'),
            ('1 ds', 'pb'),
        ])
예제 #7
0
 def test_double_token_together(self):
     # from bug 2393362, the idea is to generate 00 to 99
     # using to generators (I'm doing less iterations here)
     fg = FuzzyGenerator("-$xrange(2)$$xrange(2)$-", "")
     self.assertEqual(list(fg.generate()), [("-00-", ""), ("-01-", ""),
                                            ("-10-", ""), ("-11-", "")])
예제 #8
0
 def test_double_token_together(self):
     # from bug 2393362, the idea is to generate 00 to 99
     # using to generators (I'm doing less iterations here)
     fg = FuzzyGenerator("-$xrange(2)$$xrange(2)$-", "")
     self.assertEqual(list(fg.generate()), [
         ("-00-", ""), ("-01-", ""), ("-10-", ""), ("-11-", "")])