Ejemplo n.º 1
0
 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)))
Ejemplo n.º 2
0
 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)))
Ejemplo n.º 3
0
 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)))
Ejemplo n.º 4
0
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
Ejemplo n.º 5
0
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
Ejemplo n.º 6
0
 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)))
Ejemplo n.º 7
0
 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)))
Ejemplo n.º 8
0
 def test_one(self):
     """Work when only 1 iterable is passed."""
     self.assertEqual([0, 1], list(collate(range(2))))
Ejemplo n.º 9
0
 def make_anonymous_watches():
     for x in range(3):
         watch(event_type=TYPE, email='*****@*****.**').save()
Ejemplo n.º 10
0
 def test_one(self):
     """Work when only 1 iterable is passed."""
     self.assertEqual([0, 1], list(collate(range(2))))
Ejemplo n.º 11
0
 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)))