import unittest import urllib.request import re class TestAdminUI(unittest.TestCase): BASE_URL = 'http://localhost:8080/admin' def test_01_admin_login_page(self): """测试管理后台登录页""" url = f'{self.BASE_URL}/index.html' response = urllib.request.urlopen(url) self.assertEqual(response.status, 200) content = response.read().decode('utf-8') self.assertIn('管理后台', content) self.assertIn('用户名', content) self.assertIn('密码', content) print('✓ 管理后台登录页测试通过') def test_02_admin_page_structure(self): """测试管理后台页面结构""" url = f'{self.BASE_URL}/index.html' response = urllib.request.urlopen(url) content = response.read().decode('utf-8') self.assertIn('