You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When this assertion fails, the feedback I get isn't very readable:
'/tmp/tmpBNe_N9' matches MatchesAll(MatchesPredicate(<function exists at 0x7f0835277578>, '%s does not exist.'), MatchesPredicate(<function isdir at 0x7f0835277668>, '%s is not a directory.'))
This can be reproduced with the following:
>>> import os
>>> os.mkdir('/tmp/hello-testtools')
>>> from testtools.matchers import Not, DirExists
>>> matcher = Not(DirExists())
>>> mismatch = matcher.match('/tmp/hello-testtools')
>>> print(mismatch.describe())
'/tmp/hello-testtools' matches MatchesAll(MatchesPredicate(<function exists at 0x7f0835277578>, '%s does not exist.'), MatchesPredicate(<function isdir at 0x7f0835277668>, '%s is not a directory.'))
This is because DirExists is simply a function that returns an instance of MatchesAll:
def DirExists():
"""Matches if the path exists and is a directory."""
return MatchesAll(
PathExists(),
MatchesPredicate(os.path.isdir, "%s is not a directory."),
first_only=True)
and does not customize the __str__ method, which means we get the default MatchesAll str representation.
Being able to create new matcher types with a simple function is 'A Good Thing' (tm), but I wonder if we need a way to customise the __str__ representations of these new matchers.
Thoughts?
The text was updated successfully, but these errors were encountered:
I have a test that includes the following line:
When this assertion fails, the feedback I get isn't very readable:
This can be reproduced with the following:
This is because DirExists is simply a function that returns an instance of MatchesAll:
and does not customize the
__str__
method, which means we get the default MatchesAll str representation.Being able to create new matcher types with a simple function is 'A Good Thing' (tm), but I wonder if we need a way to customise the
__str__
representations of these new matchers.Thoughts?
The text was updated successfully, but these errors were encountered: