Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_comprehensions(self):
# Comprehensions can be separated if they contain different names
str([{tester(x) for x in [1]}, {tester(y) for y in [1]}])
# or are on different lines
str([{tester(x) for x in [1]},
{tester(x) for x in [1]}])
# or are of different types
str([{tester(x) for x in [1]}, list(tester(x) for x in [1])])
# but not if everything is the same
# noinspection PyTypeChecker
with self.assertRaises(NotOneValueFound):
str([{tester(x) for x in [1]}, {tester(x) for x in [2]}])
def test_only(self):
for n in range(5):
gen = (i for i in range(n))
if n == 1:
self.assertEqual(only(gen), 0)
else:
with self.assertRaises(NotOneValueFound):
only(gen)
def test_only(self):
for n in range(5):
gen = (i for i in range(n))
if n == 1:
self.assertEqual(only(gen), 0)
else:
with self.assertRaises(NotOneValueFound):
only(gen)