fix: insert cwd path before import referenced testcase class

This commit is contained in:
debugtalk
2020-05-26 13:14:33 +08:00
parent e0f0ea23d3
commit d878690125
10 changed files with 29 additions and 2 deletions

View File

@@ -1,5 +1,6 @@
# NOTICE: Generated By HttpRunner. DO'NOT EDIT! # NOTICE: Generated By HttpRunner. DO'NOT EDIT!
# FROM: examples/postman_echo/request_methods/request_with_functions.yml # FROM: examples/postman_echo/request_methods/request_with_functions.yml
from httprunner import HttpRunner, TConfig, TStep from httprunner import HttpRunner, TConfig, TStep

View File

@@ -1,5 +1,11 @@
# NOTICE: Generated By HttpRunner. DO'NOT EDIT! # NOTICE: Generated By HttpRunner. DO'NOT EDIT!
# FROM: examples/postman_echo/request_methods/request_with_testcase_reference.yml # FROM: examples/postman_echo/request_methods/request_with_testcase_reference.yml
import os
import sys
sys.path.insert(0, os.getcwd())
from httprunner import HttpRunner, TConfig, TStep from httprunner import HttpRunner, TConfig, TStep
from examples.postman_echo.request_methods.request_with_functions_test import ( from examples.postman_echo.request_methods.request_with_functions_test import (

View File

@@ -1,5 +1,6 @@
# NOTICE: Generated By HttpRunner. DO'NOT EDIT! # NOTICE: Generated By HttpRunner. DO'NOT EDIT!
# FROM: examples/postman_echo/request_methods/hardcode.yml # FROM: examples/postman_echo/request_methods/hardcode.yml
from httprunner import HttpRunner, TConfig, TStep from httprunner import HttpRunner, TConfig, TStep

View File

@@ -1,5 +1,6 @@
# NOTICE: Generated By HttpRunner. DO'NOT EDIT! # NOTICE: Generated By HttpRunner. DO'NOT EDIT!
# FROM: examples/postman_echo/request_methods/request_with_functions.yml # FROM: examples/postman_echo/request_methods/request_with_functions.yml
from httprunner import HttpRunner, TConfig, TStep from httprunner import HttpRunner, TConfig, TStep

View File

@@ -1,5 +1,11 @@
# NOTICE: Generated By HttpRunner. DO'NOT EDIT! # NOTICE: Generated By HttpRunner. DO'NOT EDIT!
# FROM: examples/postman_echo/request_methods/request_with_testcase_reference.yml # FROM: examples/postman_echo/request_methods/request_with_testcase_reference.yml
import os
import sys
sys.path.insert(0, os.getcwd())
from httprunner import HttpRunner, TConfig, TStep from httprunner import HttpRunner, TConfig, TStep
from examples.postman_echo.request_methods.request_with_functions_test import ( from examples.postman_echo.request_methods.request_with_functions_test import (

View File

@@ -1,5 +1,6 @@
# NOTICE: Generated By HttpRunner. DO'NOT EDIT! # NOTICE: Generated By HttpRunner. DO'NOT EDIT!
# FROM: examples/postman_echo/request_methods/request_with_variables.yml # FROM: examples/postman_echo/request_methods/request_with_variables.yml
from httprunner import HttpRunner, TConfig, TStep from httprunner import HttpRunner, TConfig, TStep

View File

@@ -1,5 +1,6 @@
# NOTICE: Generated By HttpRunner. DO'NOT EDIT! # NOTICE: Generated By HttpRunner. DO'NOT EDIT!
# FROM: examples/postman_echo/request_methods/validate_with_functions.yml # FROM: examples/postman_echo/request_methods/validate_with_functions.yml
from httprunner import HttpRunner, TConfig, TStep from httprunner import HttpRunner, TConfig, TStep

View File

@@ -1,5 +1,6 @@
# NOTICE: Generated By HttpRunner. DO'NOT EDIT! # NOTICE: Generated By HttpRunner. DO'NOT EDIT!
# FROM: examples/postman_echo/request_methods/validate_with_variables.yml # FROM: examples/postman_echo/request_methods/validate_with_variables.yml
from httprunner import HttpRunner, TConfig, TStep from httprunner import HttpRunner, TConfig, TStep

View File

@@ -22,12 +22,17 @@ make_files_cache_set: Set = set()
__TEMPLATE__ = jinja2.Template( __TEMPLATE__ = jinja2.Template(
"""# NOTICE: Generated By HttpRunner. DO'NOT EDIT! """# NOTICE: Generated By HttpRunner. DO'NOT EDIT!
# FROM: {{ testcase_path }} # FROM: {{ testcase_path }}
{% if imports_list %}
import os
import sys
sys.path.insert(0, os.getcwd())
{% endif %}
from httprunner import HttpRunner, TConfig, TStep from httprunner import HttpRunner, TConfig, TStep
{% for import_str in imports_list %} {% for import_str in imports_list %}
{{ import_str }} {{ import_str }}
{% endfor %} {% endfor %}
class {{ class_name }}(HttpRunner): class {{ class_name }}(HttpRunner):
config = TConfig(**{{ config }}) config = TConfig(**{{ config }})

View File

@@ -89,7 +89,7 @@ from examples.postman_echo.request_methods.request_with_functions_test import (
path = ["examples/postman_echo/request_methods/demo_testsuite.yml"] path = ["examples/postman_echo/request_methods/demo_testsuite.yml"]
make_files_cache_set.clear() make_files_cache_set.clear()
testcase_python_list = main_make(path) testcase_python_list = main_make(path)
# FIXME: self.assertEqual(len(testcase_python_list), 2) self.assertEqual(len(testcase_python_list), 3)
self.assertIn( self.assertIn(
"examples/postman_echo/request_methods/demo_testsuite_yml/request_with_functions_test.py", "examples/postman_echo/request_methods/demo_testsuite_yml/request_with_functions_test.py",
testcase_python_list, testcase_python_list,
@@ -98,3 +98,7 @@ from examples.postman_echo.request_methods.request_with_functions_test import (
"examples/postman_echo/request_methods/demo_testsuite_yml/request_with_testcase_reference_test.py", "examples/postman_echo/request_methods/demo_testsuite_yml/request_with_testcase_reference_test.py",
testcase_python_list, testcase_python_list,
) )
self.assertIn(
"examples/postman_echo/request_methods/request_with_functions_test.py",
testcase_python_list,
)