Code Duplication    Length = 47-51 lines in 2 locations

tests/test_examples.py 2 locations

@@ 269-319 (lines=51) @@
266
        truthy: false
267
        """) == sample.__mapper__.text
268
269
    def test_function_to_json(self, tmpdir):
270
        """Verify standard attribute types dump/load correctly (function)."""
271
        tmpdir.chdir()
272
        _sample = SampleStandard()
273
        attrs = {'object': self.StatusDictionary,
274
                 'array': IntegerList,
275
                 'string': String,
276
                 'number_int': Integer,
277
                 'number_real': Float,
278
                 'truthy': Boolean,
279
                 'falsey': Boolean}
280
        sample = yorm.sync(_sample, "path/to/directory/sample.json", attrs)
281
        assert "path/to/directory/sample.json" == sample.__mapper__.path
282
283
        # check defaults
284
        assert {'status': False} == sample.object
285
        assert [] == sample.array
286
        assert "" == sample.string
287
        assert 0 == sample.number_int
288
        assert 0.0 == sample.number_real
289
        assert True is sample.truthy
290
        assert False is sample.falsey
291
        assert None is sample.null
292
293
        # change object values
294
        sample.object = {'key': 'value'}
295
        sample.array = [1, 2, 3]
296
        sample.string = "Hello, world!"
297
        sample.number_int = 42
298
        sample.number_real = 4.2
299
        sample.truthy = None
300
        sample.falsey = 1
301
302
        # check file values
303
        assert strip("""
304
        {
305
            "array": [
306
                1,
307
                2,
308
                3
309
            ],
310
            "falsey": true,
311
            "number_int": 42,
312
            "number_real": 4.2,
313
            "object": {
314
                "status": false
315
            },
316
            "string": "Hello, world!",
317
            "truthy": false
318
        }
319
        """, tabs=2, end='') == sample.__mapper__.text
320
321
    def test_auto_off(self, tmpdir):
322
        """Verify file updates are disabled with auto save off."""
@@ 221-267 (lines=47) @@
218
        assert False is sample.truthy
219
        assert False is sample.falsey
220
221
    def test_function(self, tmpdir):
222
        """Verify standard attribute types dump/load correctly (function)."""
223
        tmpdir.chdir()
224
        _sample = SampleStandard()
225
        attrs = {'object': self.StatusDictionary,
226
                 'array': IntegerList,
227
                 'string': String,
228
                 'number_int': Integer,
229
                 'number_real': Float,
230
                 'truthy': Boolean,
231
                 'falsey': Boolean}
232
        sample = yorm.sync(_sample, "path/to/directory/sample.yml", attrs)
233
        assert "path/to/directory/sample.yml" == sample.__mapper__.path
234
235
        # check defaults
236
        assert {'status': False} == sample.object
237
        assert [] == sample.array
238
        assert "" == sample.string
239
        assert 0 == sample.number_int
240
        assert 0.0 == sample.number_real
241
        assert True is sample.truthy
242
        assert False is sample.falsey
243
        assert None is sample.null
244
245
        # change object values
246
        sample.object = {'key': 'value'}
247
        sample.array = [1, 2, 3]
248
        sample.string = "Hello, world!"
249
        sample.number_int = 42
250
        sample.number_real = 4.2
251
        sample.truthy = None
252
        sample.falsey = 1
253
254
        # check file values
255
        assert strip("""
256
        array:
257
        - 1
258
        - 2
259
        - 3
260
        falsey: true
261
        number_int: 42
262
        number_real: 4.2
263
        object:
264
          status: false
265
        string: Hello, world!
266
        truthy: false
267
        """) == sample.__mapper__.text
268
269
    def test_function_to_json(self, tmpdir):
270
        """Verify standard attribute types dump/load correctly (function)."""