Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

单元测试缺陷: pytest 无法直接执行 request_with_parameters_test.py 用例文件 #1152

Open
zhengtong0898 opened this issue Jan 16, 2022 · 0 comments
Assignees
Labels
pending pending for confirmation

Comments

@zhengtong0898
Copy link

问题描述

pytest 无法直接执行 request_with_parameters_test.py 用例文件。

pytest 无法识别 @pytest.mark.parametrize 中的 ${parameterize(request_methods/account.csv)} 执行函数片段。

版本信息

请提供如下版本信息:

  • 操作系统类型: macos
  • Python 版本 3.8.2
  • HttpRunner 版本 3.6.1
  • 设备 ID: 119394988060799

运行命令 && 堆栈信息

请提供在命令行中运行测试时所在的目录和命令,以及报错时的详细堆栈内容。

$ pwd
/Users/xxxxxxxx/PycharmProjects/httprunner-316


$ pytest examples/postman_echo/request_methods/request_with_parameters_test.py --showlocals --verbose
========================================================================================================================== test session starts ==========================================================================================================================
platform darwin -- Python 3.8.12, pytest-5.4.3, py-1.11.0, pluggy-0.13.1 -- /Users/xxxxxxxx/Library/Caches/pypoetry/virtualenvs/httprunner-01q-NmAB-py3.8/bin/python
cachedir: .pytest_cache
metadata: {'Python': '3.8.12', 'Platform': 'macOS-10.15.5-x86_64-i386-64bit', 'Packages': {'pytest': '5.4.3', 'py': '1.11.0', 'pluggy': '0.13.1'}, 'Plugins': {'metadata': '1.9.0', 'html': '2.1.1', 'anyio': '3.3.4'}, 'JAVA_HOME': '/Library/Java/JavaVirtualMachines/jdk1.8.0_291.jdk/Contents/Home'}
rootdir: /Users/xxxxxxxx/PycharmProjects/httprunner-316
plugins: metadata-1.9.0, html-2.1.1, anyio-3.3.4
collected 0 items / 1 error                                                                                                                                                                                                                                             

================================================================================================================================ ERRORS =================================================================================================================================
________________________________________________________________________________________ ERROR collecting examples/postman_echo/request_methods/request_with_parameters_test.py _________________________________________________________________________________________
examples/postman_echo/request_methods/request_with_parameters_test.py:12: in <module>
    class TestCaseRequestWithParameters(HttpRunner):
        Config     = <class 'httprunner.testcase.Config'>
        Fixtures   = <function parse_fixtures at 0x7f82d7e8d280>
        HttpRunner = <class 'httprunner.runner.HttpRunner'>
        Parameters = <function parse_parameters at 0x7f82d7e8d1f0>
        RunRequest = <class 'httprunner.testcase.RunRequest'>
        RunTestCase = <class 'httprunner.testcase.RunTestCase'>
        Step       = <class 'httprunner.testcase.Step'>
        __builtins__ = <builtins>
        __cached__ = '/Users/xxxxxxxx/PycharmProjects/httprunner-316/examples/postman_echo/request_methods/__pycache__/request_with_parameters_test.cpython-38.pyc'
        __doc__    = None
        __file__   = '/Users/xxxxxxxx/PycharmProjects/httprunner-316/examples/postman_echo/request_methods/request_with_parameters_test.py'
        __loader__ = <_pytest.assertion.rewrite.AssertionRewritingHook object at 0x7f82d7293730>
        __name__   = 'examples.postman_echo.request_methods.request_with_parameters_test'
        __package__ = 'examples.postman_echo.request_methods'
        __spec__   = ModuleSpec(name='examples.postman_echo.request_methods.request_with_parameters_test', loader=<_pytest.assertion.rewrit...Users/xxxxxxxx/PycharmProjects/httprunner-316/examples/postman_echo/request_methods/request_with_parameters_test.py')
        pytest     = <module 'pytest' from '/Users/xxxxxxxx/Library/Caches/pypoetry/virtualenvs/httprunner-01q-NmAB-py3.8/lib/python3.8/site-packages/pytest/__init__.py'>
examples/postman_echo/request_methods/request_with_parameters_test.py:15: in TestCaseRequestWithParameters
    Parameters(
        __module__ = 'examples.postman_echo.request_methods.request_with_parameters_test'
        __qualname__ = 'TestCaseRequestWithParameters'
httprunner/parser.py:519: in parse_parameters
    parsed_parameter_content: List = parse_data(
        functions_mapping = {}
        parameter_content = '${parameterize(request_methods/account.csv)}'
        parameter_content_dict = {'user_agent': 'iOS/10.2'}
        parameter_content_list = [{'user_agent': 'iOS/10.1'}, {'user_agent': 'iOS/10.2'}]
        parameter_item = ['iOS/10.2']
        parameter_name = 'username-password'
        parameter_name_list = ['username', 'password']
        parameters = {'app_version': '${get_app_version()}', 'user_agent': ['iOS/10.1', 'iOS/10.2'], 'username-password': '${parameterize(request_methods/account.csv)}'}
        parsed_parameters_list = [[{'user_agent': 'iOS/10.1'}, {'user_agent': 'iOS/10.2'}]]
        project_meta = ProjectMeta(debugtalk_py='', debugtalk_path=None, dot_env_path='', functions={}, env={}, RootDir='/Users/xxxxxxxx/PycharmProjects/httprunner-316')
httprunner/parser.py:405: in parse_data
    return parse_string(raw_data, variables_mapping, functions_mapping)
        functions_mapping = {}
        raw_data   = '${parameterize(request_methods/account.csv)}'
        variables_mapping = {}
httprunner/parser.py:340: in parse_string
    func_eval_value = func(*parsed_args, **parsed_kwargs)
        args       = ['request_methods/account.csv']
        dollar_match = None
        func       = <function load_csv_file at 0x7f82d7e69670>
        func_match = <re.Match object; span=(0, 44), match='${parameterize(request_methods/account.csv)}'>
        func_name  = 'parameterize'
        func_params_str = 'request_methods/account.csv'
        function_meta = {'args': ['request_methods/account.csv'], 'kwargs': {}}
        functions_mapping = {}
        kwargs     = {}
        match_start_position = 0
        parsed_args = ['request_methods/account.csv']
        parsed_kwargs = {}
        parsed_string = ''
        raw_string = '${parameterize(request_methods/account.csv)}'
        variables_mapping = {}
httprunner/loader.py:182: in load_csv_file
    raise exceptions.CSVNotFound(csv_file)
E   httprunner.exceptions.CSVNotFound: /Users/xxxxxxxx/PycharmProjects/httprunner-316/request_methods/account.csv
        csv_file   = '/Users/xxxxxxxx/PycharmProjects/httprunner-316/request_methods/account.csv'
---------------------------------------------------------------------------------------------------------------------------- Captured stderr ----------------------------------------------------------------------------------------------------------------------------
2022-01-16 15:00:31.494 | ERROR    | httprunner.parser:parse_string:342 - call function error:
func_name: parameterize
args: ['request_methods/account.csv']
kwargs: {}
CSVNotFound: /Users/xxxxxxxx/PycharmProjects/httprunner-316/request_methods/account.csv
======================================================================================================================== short test summary info ========================================================================================================================
ERROR examples/postman_echo/request_methods/request_with_parameters_test.py - httprunner.exceptions.CSVNotFound: /Users/xxxxxxxx/PycharmProjects/httprunner-316/request_methods/account.csv
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
=========================================================================================================================== 1 error in 0.14s ============================================================================================================================
(
@zhengtong0898 zhengtong0898 added the pending pending for confirmation label Jan 16, 2022
zhengtong0898 added a commit to zhengtong0898/httprunner that referenced this issue Jan 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending pending for confirmation
Projects
None yet
Development

No branches or pull requests

2 participants