Showing 2 of 3 files from the diff.

@@ -16,6 +16,7 @@
Loading
16 16
"""
17 17
18 18
import copy
19 +
import os
19 20
import traceback
20 21
21 22
import apiritif
@@ -226,7 +227,7 @@
Loading
226 227
    def _parse_assertion(self, item):
227 228
        sample = self.response_map.get(item.response, None)
228 229
        if sample is None:
229 -
            raise ValueError("Found assertion for unknown response")
230 +
            raise ValueError("Found assertion for unknown response: %r", item.response)
230 231
        sample.add_assertion(item.name, item.extras)
231 232
232 233
    def _parse_assertion_failure(self, item):
@@ -284,8 +285,16 @@
Loading
284 285
        req = request_event.request
285 286
        cookies = request_event.session.cookies
286 287
288 +
        resp_text = resp.text
289 +
        req_text = req.body or ""
290 +
291 +
        hard_limit = int(os.environ.get("APIRITIF_TRACE_BODY_HARDLIMIT", "0"))
292 +
        if hard_limit:
293 +
            req_text = req_text[:hard_limit]
294 +
            resp_text = resp_text[:hard_limit]
295 +
287 296
        return self._extras_dict(
288 297
            req.url, req.method, resp.status_code, resp.reason,
289 -
            dict(resp.headers), resp.text, len(resp.content), resp.elapsed.total_seconds(),
290 -
            req.body or "", cookies.get_dict(), dict(resp._request.headers)
298 +
            dict(resp.headers), resp_text, len(resp.content), resp.elapsed.total_seconds(),
299 +
            req_text, cookies.get_dict(), dict(resp._request.headers)
291 300
        )

@@ -16,6 +16,7 @@
Loading
16 16
limitations under the License.
17 17
"""
18 18
import copy
19 +
import os
19 20
import threading
20 21
import time
21 22
from functools import wraps
@@ -31,6 +32,8 @@
Loading
31 32
from apiritif.utilities import *
32 33
from apiritif.utils import headers_as_text, assert_regexp, assert_not_regexp, log, get_trace
33 34
35 +
BODY_LIMIT = int(os.environ.get("APIRITIF_TRACE_BODY_EXCLIMIT", "1024"))
36 +
34 37
35 38
class TimeoutError(Exception):
36 39
    pass
@@ -730,7 +733,7 @@
Loading
730 733
        body = self.json()
731 734
        matches = jsonpath_expr.find(body)
732 735
        if not matches:
733 -
            msg = msg or "JSONPath query %r didn't match response content: %s" % (jsonpath_query, body)
736 +
            msg = msg or "JSONPath query %r didn't match response: %s" % (jsonpath_query, self.text[:BODY_LIMIT])
734 737
            raise AssertionError(msg)
735 738
        actual_value = matches[0].value
736 739
        if expected_value is not None and actual_value != expected_value:
@@ -745,7 +748,7 @@
Loading
745 748
        body = self.json()
746 749
        matches = jsonpath_expr.find(body)
747 750
        if matches:
748 -
            msg = msg or "JSONPath query %r did match response content: %s" % (jsonpath_query, body)
751 +
            msg = msg or "JSONPath query %r did match response: %s" % (jsonpath_query, self.text[:BODY_LIMIT])
749 752
            raise AssertionError(msg)
750 753
        return self
751 754
@@ -755,7 +758,7 @@
Loading
755 758
        tree = etree.parse(BytesIO(self.content), parser)
756 759
        matches = tree.xpath(xpath_query)
757 760
        if not matches:
758 -
            msg = msg or "XPath query %r didn't match response content: %s" % (xpath_query, self.text)
761 +
            msg = msg or "XPath query %r didn't match response content: %s" % (xpath_query, self.text[:BODY_LIMIT])
759 762
            raise AssertionError(msg)
760 763
        return self
761 764
@@ -765,7 +768,7 @@
Loading
765 768
        tree = etree.parse(BytesIO(self.content), parser)
766 769
        matches = tree.xpath(xpath_query)
767 770
        if matches:
768 -
            msg = msg or "XPath query %r did match response content: %s" % (xpath_query, self.text)
771 +
            msg = msg or "XPath query %r did match response content: %s" % (xpath_query, self.text[:BODY_LIMIT])
769 772
            raise AssertionError(msg)
770 773
        return self
771 774
@@ -777,7 +780,7 @@
Loading
777 780
778 781
        matches = expected_value in vals if expected_value is not None else vals
779 782
        if not matches:
780 -
            msg = msg or "CSSSelect query %r didn't match response content: %s" % (query, self.text)
783 +
            msg = msg or "CSSSelect query %r didn't match response content: %s" % (query, self.text[:BODY_LIMIT])
781 784
            raise AssertionError(msg)
782 785
        return self
783 786
@@ -788,7 +791,7 @@
Loading
788 791
        except AssertionError:
789 792
            return self
790 793
791 -
        msg = msg or "CSSSelect query %r did match response content: %s" % (query, self.text)
794 +
        msg = msg or "CSSSelect query %r did match response content: %s" % (query, self.text[:BODY_LIMIT])
792 795
        raise AssertionError(msg)
793 796
794 797
    # TODO: assertTiming? to assert response time / connection time
Files Coverage
apiritif 82.42%
tests 97.63%
Project Totals (25 files) 87.87%
507.2
TRAVIS_PYTHON_VERSION=3.7
TRAVIS_OS_NAME=linux
507.1
TRAVIS_PYTHON_VERSION=3.6
TRAVIS_OS_NAME=linux
507.3
TRAVIS_PYTHON_VERSION=3.8
TRAVIS_OS_NAME=linux

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading