Code Duplication    Length = 12-12 lines in 3 locations

tests/test_tpm.py 3 locations

@@ 323-334 (lines=12) @@
320
        resource_file = os.path.normpath(request_path)
321
        data_file = open(resource_file)
322
        data = sorted(json.load(data_file), key=lambda k: k['id'])
323
        with requests_mock.Mocker() as m:
324
            fake_data(request_url, m)
325
            response = sorted(self.client.list_passwords_archived(), key=lambda k: k['id'])
326
        self.assertEqual(data, response)
327
328
    def test_function_list_passwords_favorite(self):
329
        """Test function list_passwords_favorite."""
330
        path_to_mock = 'passwords/favorite.json'
331
        request_url = api_url + path_to_mock
332
        request_path = local_path + path_to_mock
333
        resource_file = os.path.normpath(request_path)
334
        data_file = open(resource_file)
335
        data = sorted(json.load(data_file), key=lambda k: k['id'])
336
        with requests_mock.Mocker() as m:
337
            fake_data(request_url, m)
@@ 310-321 (lines=12) @@
307
        resource_file = os.path.normpath(request_path)
308
        data_file = open(resource_file)
309
        data = sorted(json.load(data_file), key=lambda k: k['id'])
310
        with requests_mock.Mocker() as m:
311
            fake_data(request_url, m)
312
            response = sorted(self.client.list_passwords(), key=lambda k: k['id'])
313
        self.assertEqual(data, response)
314
315
    def test_function_list_passwords_archived(self):
316
        """Test function list_passwords_archived."""
317
        path_to_mock = 'passwords/archived.json'
318
        request_url = api_url + path_to_mock
319
        request_path = local_path + path_to_mock
320
        resource_file = os.path.normpath(request_path)
321
        data_file = open(resource_file)
322
        data = sorted(json.load(data_file), key=lambda k: k['id'])
323
        with requests_mock.Mocker() as m:
324
            fake_data(request_url, m)
@@ 297-308 (lines=12) @@
294
    with requests_mock.Mocker() as m:
295
        fake_data(request_url, m)
296
        global Passwords
297
        Passwords = client.list_passwords()
298
299
    def setUp(self):
300
        self.client = tpm.TpmApiv4('https://tpm.example.com', username='USER', password='PASS')
301
302
    def test_function_list_passwords(self):
303
        """Test function list_passwords."""
304
        path_to_mock = 'passwords.json'
305
        request_url = api_url + path_to_mock
306
        request_path = local_path + path_to_mock
307
        resource_file = os.path.normpath(request_path)
308
        data_file = open(resource_file)
309
        data = sorted(json.load(data_file), key=lambda k: k['id'])
310
        with requests_mock.Mocker() as m:
311
            fake_data(request_url, m)