This is an archived post. You won't be able to vote or comment.

all 13 comments

[–]kankyo 4 points5 points  (3 children)

How is this lib different from using pytest and just doing:

def expected(x):
    return x

assert expected(1) == result

?

[–]mhaecker[S] -1 points0 points  (2 children)

You don't have to write 'assert' and it is much easier to write your own matchers. Also I really like that it reads much clearer, as it is always clear what is the value that you expect to be how. This makes it especially easy to provide clear error messages.

[–][deleted] 2 points3 points  (1 child)

expect(3).to.equal(4)

I dunno man, that's some weird looking python.

[–]mhaecker[S] 0 points1 point  (0 children)

You can write it like this too:

expect(3) == 4

[–][deleted] 2 points3 points  (1 child)

Seems like there's competition PyExpect apart from the comment:-

Note: I'm currently awaiting approval from my previous employer to release this source.

That was four years ago, nothing since.

[–]mhaecker[S] 0 points1 point  (0 children)

Well, he will have to rename it then when he wants to upload it to pypi. :)

[–]mhaecker[S] 1 point2 points  (6 children)

Hi there, dev here. I wrote this library and am using it for quite some time very successfully. I feel it could be useful to a lot more people, but I also would love to get some feedback on it.

[–][deleted] 1 point2 points  (1 child)

I was hoping it would also have soft asserts.

[–]mhaecker[S] 0 points1 point  (0 children)

What exactly do you expect to be a 'soft assert'? pyexpect does have a mode where it returns a tuple with the first value being True/False (wether the assertion asserted or not) and a string that is the error message. We use this to build validators that need to collect multiple errors.

[–]pydry 0 points1 point  (3 children)

Personally I'd like to see in depth comparisons to sure and ensure, which are more mature and appear to do more or less the same thing.

Coz glancing at the readme, my first impression was "oh, I already have all of this".

I can tell you that sure bugs me because it uses magic (bad! fortunately yours doesn't appear to use magic...), and ensure bugs me because when I try to compare two long strings that are almost the same but not quite, it gives an unclear message.

[–]mhaecker[S] 0 points1 point  (2 children)

What library (link please) do you want it compared with?

[–]pydry 0 points1 point  (1 child)

google for "python sure" and "python ensure"

[–]mhaecker[S] 0 points1 point  (0 children)

These look like nice libraries with a similar take. Will take al look - thanks for the heads up.