def test_reverse(self): """Test the `reverse` kwarg.""" iterables = [range(4, 0, -1), range(7, 0, -1), range(3, 6, -1)] self.assertEqual(sorted(reduce(list.__add__, [list(it) for it in iterables]), reverse=True), list(collate(*iterables, reverse=True)))
def test_key(self): """Test using a custom `key` function.""" iterables = [range(5, 0, -1), range(4, 0, -1)] self.assertEqual(list(sorted(reduce(list.__add__, [list(it) for it in iterables]), reverse=True)), list(collate(*iterables, key=lambda x: -x)))
def test_key(self): """Test using a custom `key` function.""" iterables = [range(5, 0, -1), range(4, 0, -1)] self.assertEqual( list( sorted(reduce(list.__add__, [list(it) for it in iterables]), reverse=True)), list(collate(*iterables, key=lambda x: -x)))
def user(save=False, **kwargs): defaults = {'password': '******'} if 'username' not in kwargs: defaults['username'] = ''.join(random.choice(ascii_letters) for x in range(15)) defaults.update(kwargs) u = get_user_model()(**defaults) if save: u.save() return u
def user(save=False, **kwargs): defaults = { 'password': '******' } if 'username' not in kwargs: defaults['username'] = ''.join( random.choice(ascii_letters) for x in range(15)) defaults.update(kwargs) u = get_user_model()(**defaults) if save: u.save() return u
def test_default(self): """Test with the default `key` function.""" iterables = [range(4), range(7), range(3, 6)] self.assertEqual( sorted(reduce(list.__add__, [list(it) for it in iterables])), list(collate(*iterables)))
def test_reverse(self): """Test the `reverse` kwarg.""" iterables = [range(4, 0, -1), range(7, 0, -1), range(3, 6, -1)] self.assertEqual( sorted(reduce(list.__add__, [list(it) for it in iterables]), reverse=True), list(collate(*iterables, reverse=True)))
def test_one(self): """Work when only 1 iterable is passed.""" self.assertEqual([0, 1], list(collate(range(2))))
def make_anonymous_watches(): for x in range(3): watch(event_type=TYPE, email='*****@*****.**').save()
def test_default(self): """Test with the default `key` function.""" iterables = [range(4), range(7), range(3, 6)] self.assertEqual(sorted(reduce(list.__add__, [list(it) for it in iterables])), list(collate(*iterables)))