svanoort / pyresttest

Python Rest Testing
Apache License 2.0
1.15k stars 325 forks source link

'lt' aren't working with values greater than 999 #190

Closed thebino closed 8 years ago

thebino commented 8 years ago
- validators:
    - compare: {header: "content-length", comparator: gt, expected: '200'}
    - compare: {header: "content-length", comparator: lt, expected: '600'}

ERROR:Test Failure, failure type: Validator Failed, Reason: Comparison failed, evaluating lt(611, 200) returned False

- compare: {header: "content-length", comparator: lt, expected: '700'}
...
- compare: {header: "content-length", comparator: lt, expected: '999'}

Tests till 999 passes

- compare: {header: "content-length", comparator: lt, expected: '1000'}

Test failed again

svanoort-jenkins commented 8 years ago

This is a variable typing issue, headers are strings, not integers, so you are comparing alphabetically not numerically. You might try a regex comparator here. On Apr 2, 2016 6:26 AM, "Benjamin Stürmer" notifications@github.com wrote:

  • validators:
    • compare: {header: "content-length", comparator: gt, expected: '200'}
    • compare: {header: "content-length", comparator: lt, expected: '600'}

ERROR:Test Failure, failure type: Validator Failed, Reason: Comparison failed, evaluating lt(611, 200) returned False

  • compare: {header: "content-length", comparator: lt, expected: '700'} ...
  • compare: {header: "content-length", comparator: lt, expected: '999'}

Tests till 999 passes

  • compare: {header: "content-length", comparator: lt, expected: '1000'}

Test failed again

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/svanoort/pyresttest/issues/190

thebino commented 8 years ago

Ah I see. So this works for me as well.

# content-length between 200 - 2.999
- compare: {header: "content-length", comparator: "regex", expected: '(^[2-9][0-9]{2}$)|(^[1-2][0-9]{3}$)'}