IBM / gauge-api-steps

A Python module providing reusable Gauge steps for API testing
MIT License
7 stars 2 forks source link

Better support for binary files #60

Open derdualist opened 4 weeks ago

derdualist commented 4 weeks ago

The Steps and functional expressions to load files are limited to regular text files. Binary files should generally be supported, too. At least in reasonable cases, like setting a request body.

There is also an error when a binary response is logged:

Error in * Request <> <>:

Error Message: 'unicodeescape' codec can't decode bytes in position 12867-12868: truncated \UXXXXXXXX escape
        Stacktrace: 
        Traceback (most recent call last):
          File "/Users/<user>/Library/Python/3.10/lib/python/site-packages/getgauge/executor.py", line 33, in execute_method
            step.impl(*params)
          File "/Users/<user>/Library/Python/3.10/lib/python/site-packages/gauge_api_steps/api_steps.py", line 199, in make_request
            report_response_info(resp, resp_body)
          File "/Users/<user>/Library/Python/3.10/lib/python/site-packages/gauge_api_steps/reporting.py", line 41, in report_response_info
            print_and_report(f"< {resp_body.decode('unicode_escape')}")
        UnicodeDecodeError: 'unicodeescape' codec can't decode bytes in position 12867-12868: truncated \UXXXXXXXX escape