reportportal / agent-python-pytest

Framework integration with PyTest
Apache License 2.0
94 stars 103 forks source link

TypeError for 'attachment' argument when disabling integration. #331

Closed IgStep closed 1 year ago

IgStep commented 1 year ago

Description "Unexpected keyword argument 'attachment'" error is thrown when running tests with no:pytest_reportportal option.

Steps to Reproduce

  1. Create test function using rp_logger fixture.
  2. Inside test function use rp_logger to save attachement, for example: rp_logger().info("Create request", attachment={ "data": json.dumps(data), "mime": "application/json"}).
  3. Run tests with no:pytest_reportportal option, for example: pytest -p no:pytest_reportportal tests
  4. Pay attention to the error traceback.

Expected behavior Test function passed without reporting results to Report Portal instance.

Actual behavior Test function failed because of TypeError: Logger._log() got an unexpected keyword argument 'attachment'

Package versions Python 3.10.1, pytest-reportportal 5.1.5, pytest 7.2.2

Additional context If tests are run just without --reportportal option, behavior the same.

HardNorth commented 1 year ago

@IgStep It's expected, since core python does not have 'attachment' parameter on logging functions. You can setup your logging through custom handler as in example here, to avoid such exception: https://github.com/reportportal/agent-python-pytest#examples