Code Duplication    Length = 16-24 lines in 3 locations

tests/test_default_values.py 3 locations

@@ 76-99 (lines=24) @@
73
    expect(bar.foo.var3) == 'f'
74
75
76
def test_init_defaults_are_ignored_when_attributes_exist(expect, tmpdir):
77
    tmpdir.chdir()
78
    bar = Bar()
79
80
    log.info('#' * 50)
81
82
    bar.__mapper__.text = strip("""
83
    var1: bar-var1
84
    var2: bar-var2
85
    var3: bar-var3
86
    foo:
87
      var1: foo-var1
88
      var2: foo-var2
89
      var3: foo-var3
90
    """)
91
92
    log.info('#' * 50)
93
94
    expect(bar.var1) == 'bar-var1'
95
    expect(bar.var2) == 'bar-var2'
96
    expect(bar.var3) == 'bar-var3'
97
    expect(bar.foo.var1) == 'foo-var1'
98
    expect(bar.foo.var2) == 'foo-var2'
99
    expect(bar.foo.var3) == 'foo-var3'
100
@@ 54-73 (lines=20) @@
51
    expect(bar.foo.var3) == ''
52
53
54
def test_init_defaults_are_applied_when_attributes_are_missing(expect, tmpdir):
55
    tmpdir.chdir()
56
    bar = Bar()
57
58
    log.info('#' * 50)
59
60
    bar.__mapper__.text = strip("""
61
    var3: e
62
    foo:
63
      var3: f
64
    """)
65
66
    log.info('#' * 50)
67
68
    expect(bar.var1) == 'c'
69
    expect(bar.var2) == 'd'
70
    expect(bar.var3) == 'e'
71
    expect(bar.foo.var1) == 'a'
72
    expect(bar.foo.var2) == 'b'
73
    expect(bar.foo.var3) == 'f'
74
75
76
def test_init_defaults_are_ignored_when_attributes_exist(expect, tmpdir):
@@ 36-51 (lines=16) @@
33
        self.foo = foo or Foo()
34
35
36
def test_init_defaults_are_applied_when_blank(expect, tmpdir):
37
    tmpdir.chdir()
38
    bar = Bar()
39
40
    log.info('#' * 50)
41
42
    bar.__mapper__.text = ""
43
44
    log.info('#' * 50)
45
46
    expect(bar.var1) == 'c'
47
    expect(bar.var2) == 'd'
48
    expect(bar.var3) == ''
49
    expect(bar.foo.var1) == 'a'
50
    expect(bar.foo.var2) == 'b'
51
    expect(bar.foo.var3) == ''
52
53
54
def test_init_defaults_are_applied_when_attributes_are_missing(expect, tmpdir):