How to use funcy - 10 common examples

To help you get started, we’ve selected a few funcy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github getredash / redash / tests / test_handlers.py View on Github external
description='y',
            snippet='z',
            user=self.factory.user,
            org=self.factory.org
        )
        models.db.session.add(qs)
        models.db.session.commit()
        res = self.make_request(
            'get',
            '/api/query_snippets',
            user=self.factory.user)
        self.assertEqual(res.status_code, 200)
        data = res.json
        self.assertEqual(len(data), 1)
        self.assertEqual(
            project(data[0], ['id', 'trigger', 'description', 'snippet']), {
                'id': 1,
                'trigger': 'x',
                'description': 'y',
                'snippet': 'z',
            })
        self.assertEqual(qs.trigger, 'x')
        self.assertEqual(qs.description, 'y')
        self.assertEqual(qs.snippet, 'z')
github jsmesami / naovoce / tests / api / v1 / test_signup.py View on Github external
def test_signup_missing_args(client, signup_email_request_data, missing_arg, error_msg):
    response = client.post(
        reverse('api:signup'),
        funcy.omit(signup_email_request_data(), [missing_arg]),
        content_type='application/json',
    )

    assert response.status_code == status.HTTP_400_BAD_REQUEST
    assert response.json() == error_msg
github jsmesami / naovoce / tests / api / v1 / test_fruit.py View on Github external
def test_fruit_create_missing_args(client, random_password, new_user, fruit_request_data, missing_arg, error_msg):
    password = random_password()
    user = new_user(password=password)

    assert client.login(username=user.username, password=password)

    response = client.post(
        reverse('api:fruit-list'),
        funcy.omit(fruit_request_data(), [missing_arg]),
        content_type='application/json',
    )

    assert response.status_code == status.HTTP_400_BAD_REQUEST
    assert response.json() == error_msg
github Suor / funcy / tests / test_seqs.py View on Github external
def test_lsplit():
    assert lsplit(_ % 2, range(5)) == ([1, 3], [0, 2, 4])
    # This behaviour moved to split_at()
    with pytest.raises(TypeError): lsplit(2, range(5))
github getredash / redash / tests / handlers / test_groups.py View on Github external
def filtergroups(gs):
            return [project(g, g_keys) for g in gs]
        self.assertEqual(filtergroups(response.json),
github Suor / funcy / tests / test_seqs.py View on Github external
def test_pairwise():
    assert list(pairwise(range(3))) == [(0, 1), (1, 2)]
github Suor / funcy / tests / test_seqs.py View on Github external
def test_with_next():
    assert list(with_next(range(3))) == [(0, 1), (1, 2), (2, None)]
github Suor / funcy / tests / test_seqs.py View on Github external
def test_with_prev():
    assert list(with_prev(range(3))) == [(0, None), (1, 0), (2, 1)]
github Suor / funcy / tests / test_types.py View on Github external
def test_iterable():
    assert iterable([])
    assert iterable({})
    assert iterable('abc')
    assert iterable(iter([]))
    assert iterable(x for x in range(10))
    assert iterable(range(10))

    assert not iterable(1)
github Suor / funcy / tests / test_seqs.py View on Github external
def test_chunks():
    assert lchunks(2, [0, 1, 2, 3, 4]) == [[0, 1], [2, 3], [4]]
    assert lchunks(2, 1, [0, 1, 2, 3]) == [[0, 1], [1, 2], [2, 3], [3]]
    assert lchunks(3, 1, iter(range(3))) == [[0, 1, 2], [1, 2], [2]]