File: test_emptiness.py

package info (click to toggle)
preggy 1.4.4-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 408 kB
  • sloc: python: 1,929; makefile: 22; sh: 8
file content (47 lines) | stat: -rw-r--r-- 996 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# -*- coding: utf-8 -*-

# preggy assertions
# https://github.com/heynemann/preggy

# Licensed under the MIT license:
# http://www.opensource.org/licenses/mit-license
# Copyright (c) 2013 Bernardo Heynemann heynemann@gmail.com

from preggy import expect

#-----------------------------------------------------------------------------

EMPTY_DATA = (
    '',
    [],
    {},
    tuple([])
)

NOT_EMPTY_DATA = (
    'qwe',
    [1],
    {'a': 'b'},
    tuple([2])
)

#-----------------------------------------------------------------------------

def is_empty(item):
    expect(item).to_be_empty()


def is_not_empty(item):
    expect(item).Not.to_be_empty()
    expect(item).not_to_be_empty()

#-----------------------------------------------------------------------------

def test_emptiness_assertion_works():
    for empty_item in EMPTY_DATA:
        is_empty(empty_item)


def test_not_emptiness_assertion_works():
    for not_empty_item in NOT_EMPTY_DATA:
        is_not_empty(not_empty_item)