Completed
Push — develop ( 37ee14...fa703e )
by Jace
02:24
created

tests.test_existing_files_are_reorderd()   A

Complexity

Conditions 2

Size

Total Lines 20

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 2
dl 0
loc 20
rs 9.4285
1
# pylint: disable=redefined-outer-name,expression-not-assigned,attribute-defined-outside-init,no-member
2
3
from expecter import expect
0 ignored issues
show
Configuration introduced by
The import expecter could not be resolved.

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
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
def test_attribute_order_is_maintained(tmpdir):
21
    tmpdir.chdir()
22
    sample = Sample()
23
    sample.string = "Hello, world!"
24
    sample.number_int = 42
25
    sample.number_real = 4.2
26
    sample.truthy = False
27
    sample.falsey = True
28
29
    expect(sample.__mapper__.text) == strip("""
30
    string: Hello, world!
31
    number_int: 42
32
    number_real: 4.2
33
    truthy: false
34
    falsey: true
35
    """)
36
37
38
def test_existing_files_are_reorderd(tmpdir):
39
    tmpdir.chdir()
40
    with open("sample.yml", 'w') as stream:
41
        stream.write(strip("""
42
        falsey: 1
43
        number_int: 2
44
        number_real: 3
45
        string: 4
46
        truthy: 5
47
        """))
48
    sample = Sample()
49
    sample.falsey = 0
50
51
    expect(sample.__mapper__.text) == strip("""
52
    string: 4
53
    number_int: 2
54
    number_real: 3.0
55
    truthy: true
56
    falsey: false
57
    """)
58