'Pseudo-random number of vulnerabilities found in audit phase (xss)
https://github.com/andresriancho/w3af/issues/1557'

def test_1557_random_number_of_results(self):

    script = (TEST_SCRIPT_1557 % (OUTPUT_PATH, get_wavsep_http()))
    file(SCRIPT_PATH, 'w').write(script)
    python_executable = sys.executable
    VULN_STRING = 'A    Cross    Site    Scripting    vulnerability    was    found    at'
    URL_VULN_RE = re.compile(('%s:    "(.*?)"' % VULN_STRING))
    all_previous_vulns = []
    loops = (2 if is_running_on_ci() else 10)
    for i in xrange(loops):
        print ('Start    run    #%s' % i)
        found_vulns = set()
        p = subprocess.Popen([python_executable, 'w3af_console', '-n', '-s', SCRIPT_PATH], stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE, shell=False, universal_newlines=True)
        (stdout, stderr) = p.communicate()
        i_vuln_count = stdout.count(VULN_STRING)
        print ('%s    vulnerabilities    found' % i_vuln_count)
        self.assertNotEqual(i_vuln_count, 0, stdout)
        for line in stdout.split('\n'):
            if (VULN_STRING in line):
                found_vulns.add(URL_VULN_RE.search(line).group(1))
        for previous_found in all_previous_vulns:
            self.assertEqual(found_vulns, previous_found)
        all_previous_vulns.append(found_vulns)
