Skip to content

Commit

Permalink
Merge pull request #8303 from pradyunsg/nicer-test-helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
pradyunsg committed May 23, 2020
2 parents f84f91a + 2552151 commit 7d875fa
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,27 @@ def assert_installed(self, pkg_name, editable=True, with_files=[],
.format(**locals())
)

def did_create(self, path, message=None):
assert str(path) in self.files_created, _one_or_both(message, self)

def did_not_create(self, path, message=None):
assert str(path) not in self.files_created, _one_or_both(message, self)

def did_update(self, path, message=None):
assert str(path) in self.files_updated, _one_or_both(message, self)

def did_not_update(self, path, message=None):
assert str(path) not in self.files_updated, _one_or_both(message, self)


def _one_or_both(a, b):
"""Returns f"{a}\n{b}" if a is truthy, else returns str(b).
"""
if not a:
return str(b)

return "{a}\n{b}".format(a=a, b=b)


def make_check_stderr_message(stderr, line, reason):
"""
Expand Down

0 comments on commit 7d875fa

Please sign in to comment.