Skip to content
This repository has been archived by the owner on Aug 26, 2021. It is now read-only.

Commit

Permalink
made pred functions anonymous/made default pred lambda test: True
Browse files Browse the repository at this point in the history
  • Loading branch information
JosephFKnight committed May 27, 2019
1 parent 91e90fc commit 977b3c9
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions distest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def __init__(self, target_name, collector: TestCollector, timeout=5):
self.timeout = timeout
self.failure = False

async def _run_by_predicate(self, channel, predicate):
async def _run_by_predicate(self, channel, predicate=lambda test: True):
for test in self._tests:
if predicate(test):
await channel.send("**Running test {}**".format(test.name))
Expand Down Expand Up @@ -129,19 +129,15 @@ async def run_tests(self, channel: discord.TextChannel, name: str):
"""
print("Running test:", name)
if name == "all":
await self._run_by_predicate(channel, lambda t: True)
await self._run_by_predicate(channel)
elif name == "unrun":

def pred(t):
return t.result is TestResult.UNRUN

await self._run_by_predicate(channel, pred)
await self._run_by_predicate(
channel, lambda test: test.result is TestResult.UNRUN
)
elif name == "failed":

def pred(t):
return t.result is TestResult.FAILED

await self._run_by_predicate(channel, pred)
await self._run_by_predicate(
channel, lambda test: test.result is TestResult.FAILED
)
elif self._tests.find_by_name(name) is None:
text = ":x: There is no test called `{}`"
await channel.send(message.channel, text.format(name))
Expand Down

0 comments on commit 977b3c9

Please sign in to comment.