Code Duplication    Length = 18-20 lines in 2 locations

tests/test_webui.py 2 locations

@@ 112-131 (lines=20) @@
109
        self.assertIsNotNone(m)
110
        self.assertIn('__START_URL__', json.loads(m.group(1)))
111
112
    def test_25_debug_post(self):
113
        rv = self.app.post('/debug/test_project', data={
114
            'project-name': 'other_project',
115
            'start-urls': 'http://127.0.0.1:14887/pyspider/test.html',
116
            'script-mode': 'script',
117
        })
118
        self.assertEqual(rv.status_code, 200)
119
        self.assertIn(b'debugger', rv.data)
120
        self.assertIn(b'var task_content = ', rv.data)
121
        self.assertIn(b'var script_content = ', rv.data)
122
123
        m = re.search(r'var task_content = (.*);\n', utils.text(rv.data))
124
        self.assertIsNotNone(m)
125
        self.assertIn('test_project', m.group(1))
126
        self.__class__.task_content = json.loads(m.group(1))
127
128
        m = re.search(r'var script_content = (.*);\n', utils.text(rv.data))
129
        self.assertIsNotNone(m)
130
        self.assertIn('127.0.0.1:14887', m.group(1))
131
        self.__class__.script_content = json.loads(m.group(1))
132
133
    def test_30_run(self):
134
        rv = self.app.post('/debug/test_project/run', data={
@@ 285-302 (lines=18) @@
282
        self.assertGreater(data['test_project']['1d']['success'], 3)
283
        self.assertGreater(data['test_project']['all']['success'], 3)
284
285
    def test_a20_tasks(self):
286
        rv = self.app.get('/tasks')
287
        self.assertEqual(rv.status_code, 200, rv.data)
288
        self.assertIn(b'SUCCESS</span>', rv.data)
289
        self.assertNotIn(b'>ERROR</span>', rv.data)
290
        m = re.search(r'/task/test_project:[^"]+', utils.text(rv.data))
291
        self.assertIsNotNone(m)
292
        self.__class__.task_url = m.group(0)
293
        self.assertIsNotNone(self.task_url)
294
        m = re.search(r'/debug/test_project[^"]+', utils.text(rv.data))
295
        self.assertIsNotNone(m)
296
        self.__class__.debug_task_url = m.group(0)
297
        self.assertIsNotNone(self.debug_task_url)
298
299
        rv = self.app.get('/tasks?project=test_project')
300
        self.assertEqual(rv.status_code, 200)
301
        self.assertIn(b'SUCCESS</span>', rv.data)
302
        self.assertNotIn(b'>ERROR</span>', rv.data)
303
304
    def test_a22_active_tasks(self):
305
        rv = self.app.get('/active_tasks')