Completed
Push — develop ( ac1289...37ee14 )
by Jace
6s
created

tests.sample()   A

Complexity

Conditions 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 1
dl 0
loc 4
rs 10
1
# pylint: disable=redefined-outer-name
2
3
import pytest
4
5
import yorm
6
7
from . import strip
8
9
10
@yorm.attr(string=yorm.types.String)
11
@yorm.attr(number_int=yorm.types.Integer)
12
@yorm.attr(number_real=yorm.types.Float)
13
@yorm.attr(truthy=yorm.types.Boolean)
14
@yorm.attr(falsey=yorm.types.Boolean)
15
@yorm.sync("sample.yml")
16
class Sample:
17
    """Sample class with ordered attributes."""
18
19
20
@pytest.fixture
21
def sample(tmpdir):
22
    tmpdir.chdir()
23
    return Sample()
24
25
26
def test_attribute_order_is_maintained(sample):
27
    sample.string = "Hello, world!"
28
    sample.number_int = 42
29
    sample.number_real = 4.2
30
    sample.truthy = False
31
    sample.falsey = True
32
33
    assert strip("""
34
    string: Hello, world!
35
    number_int: 42
36
    number_real: 4.2
37
    truthy: false
38
    falsey: true
39
    """) == sample.__mapper__.text
40