示例#1
0
 def test_create_suite(self):
     testcase_file_path = os.path.join(
         os.getcwd(), 'tests/data/demo_testset_variables.yml')
     testset = load_test_file(testcase_file_path)
     suite = task.TestSuite(testset)
     self.assertEqual(suite.countTestCases(), 3)
     for testcase in suite:
         self.assertIsInstance(testcase, task.TestCase)
示例#2
0
def gen_locustfile(testcase_file_path):
    """ generate locustfile from template.
    """
    locustfile_path = 'locustfile.py'
    template_path = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                                 'locustfile_template')
    testset = load_test_file(testcase_file_path)
    host = testset.get("config", {}).get("request", {}).get("base_url", "")

    with io.open(template_path, encoding='utf-8') as template:
        with io.open(locustfile_path, 'w', encoding='utf-8') as locustfile:
            template_content = template.read()
            template_content = template_content.replace("$HOST", host)
            template_content = template_content.replace(
                "$TESTCASE_FILE", testcase_file_path)
            locustfile.write(template_content)

    return locustfile_path
示例#3
0
def gen_locustfile(testcase_file_path):
    """ generate locustfile from template.
    """
    locustfile_path = 'locustfile.py'
    template_path = os.path.join(
        os.path.dirname(os.path.realpath(__file__)),
        'locustfile_template'
    )
    testset = load_test_file(testcase_file_path)
    host = testset.get("config", {}).get("request", {}).get("base_url", "")

    with io.open(template_path, encoding='utf-8') as template:
        with io.open(locustfile_path, 'w', encoding='utf-8') as locustfile:
            template_content = template.read()
            template_content = template_content.replace("$HOST", host)
            template_content = template_content.replace("$TESTCASE_FILE", testcase_file_path)
            locustfile.write(template_content)

    return locustfile_path