Skip to content

Commit 7d875fa

Browse files
authored
Merge pull request #8303 from pradyunsg/nicer-test-helpers
2 parents f84f91a + 2552151 commit 7d875fa

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/lib/__init__.py

+21
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,27 @@ def assert_installed(self, pkg_name, editable=True, with_files=[],
353353
.format(**locals())
354354
)
355355

356+
def did_create(self, path, message=None):
357+
assert str(path) in self.files_created, _one_or_both(message, self)
358+
359+
def did_not_create(self, path, message=None):
360+
assert str(path) not in self.files_created, _one_or_both(message, self)
361+
362+
def did_update(self, path, message=None):
363+
assert str(path) in self.files_updated, _one_or_both(message, self)
364+
365+
def did_not_update(self, path, message=None):
366+
assert str(path) not in self.files_updated, _one_or_both(message, self)
367+
368+
369+
def _one_or_both(a, b):
370+
"""Returns f"{a}\n{b}" if a is truthy, else returns str(b).
371+
"""
372+
if not a:
373+
return str(b)
374+
375+
return "{a}\n{b}".format(a=a, b=b)
376+
356377

357378
def make_check_stderr_message(stderr, line, reason):
358379
"""

0 commit comments

Comments
 (0)