# -*- coding: utf-8 -*- """ 中华人民共和国广告法文案合规自动化专项测试 (Ad Law Compliance Test Suite) 严格依据《中华人民共和国广告法》第4条、第8条、第9条、第11条、第28条: 1. 绝对化极限词禁止(第九条第(三)项):最高、最佳、第一、顶级、极致、极速、独家、独创、行业领先等。 2. 国家机关名义与国家级禁用(第九条第(二)、(三)项):严禁使用“国家级认定/国家级项目”等违法定性。 3. 绝对化与夸大承诺禁止(第四条、第二十八条):严禁使用“彻底解决”、“彻底杜绝”、“100%准确”等绝对化承诺。 4. 认证资质与引证规范(第八条、第十一条):规范使用法定全称,杜绝无依据的“权威资质”自我标榜。 """ import os import re import unittest ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) class TestAdLawCompliance(unittest.TestCase): def setUp(self): self.target_files = { 'index_pc': os.path.join(ROOT_DIR, 'addons/official/view/web/official_home/index.html'), 'index_m': os.path.join(ROOT_DIR, 'addons/official/view/web/official_home/index_e.html'), 'single_pc': os.path.join(ROOT_DIR, 'addons/official/view/web/official_home/single.html'), 'single_m': os.path.join(ROOT_DIR, 'addons/official/view/web/official_home/single_e.html'), 'service_pc': os.path.join(ROOT_DIR, 'addons/official/view/web/official_product/service_page.html'), 'product_pc': os.path.join(ROOT_DIR, 'addons/official/view/web/official_product/product_page.html'), 'case_pc': os.path.join(ROOT_DIR, 'addons/official/view/web/official_case_show/list.html'), 'case_m': os.path.join(ROOT_DIR, 'addons/official/view/web/official_case_show/list_e.html'), 'contact_pc': os.path.join(ROOT_DIR, 'addons/official/view/web/official_online_message/list.html'), 'nav_pc': os.path.join(ROOT_DIR, 'addons/official/view/web/official_common/pc/nav.html'), } self.contents = {} for key, path in self.target_files.items(): if os.path.exists(path): with open(path, 'r', encoding='utf-8') as f: self.contents[key] = f.read() else: self.contents[key] = "" # 合并所有页面文本 self.all_text = "\n".join(self.contents.values()) def test_no_extreme_words_ban(self): """广告法第九条第(三)项:严禁使用绝对化极限用词""" extreme_words = [ '极致', '极速', '顶级', '首选', '独家', '独创', '行业领先', '首屈一指', '绝无仅有', '世界级', '第一品牌', '遥遥领先' ] for word in extreme_words: self.assertNotIn(word, self.all_text, f"文案中严禁出现广告法违禁极限词: '{word}'") def test_no_illegal_national_level_claims(self): """广告法第九条第(二)、(三)项:严禁非法使用'国家级'修饰语""" # 严禁出现“国家级认定”、“国家级自主研发”等违法表述 self.assertNotIn('国家级自主研发', self.all_text, "不得使用'国家级自主研发'违规修饰") self.assertNotIn('国家级科技创新认定', self.all_text, "不得使用'国家级科技创新认定'违规表述") # 合规的表达应当为官方备案机构或高新技术企业全称 self.assertIn('全国高新技术企业认定管理机构备案认定', self.contents['single_pc'], "资质表述须符合法定规范,应使用全国高新技术企业认定管理机构备案认定") def test_no_absolute_guarantee_and_exaggeration(self): """广告法第四条/第二十八条:严禁绝对化与夸大免责承诺""" # 严禁“彻底杜绝”、“彻底解决”、“彻底消除” absolute_promises = ['彻底解决', '彻底杜绝', '彻底消除', '永不宕机', '零故障', '零风险'] for p in absolute_promises: self.assertNotIn(p, self.all_text, f"文案中不得出现绝对化夸大承诺: '{p}'") def test_no_absolute_percentage_guarantees(self): """广告法合规:服务与指标承诺中杜绝'100%'绝对化宣传""" # 过滤 CSS 中的技术属性后,文案内容不应包含绝对化的 100% 承诺 clean_text = re.sub(r'[\'\"a-zA-Z0-9_\-:]*\s*:\s*100%', '', self.all_text) clean_text = re.sub(r'width\s*=\s*[\'\"]100%[\'\"]', '', clean_text) clean_text = re.sub(r'height\s*=\s*[\'\"]100%[\'\"]', '', clean_text) self.assertNotIn('准确率: 100%', clean_text, "分账准确率不得夸大承诺100%") self.assertNotIn('自动对账率: 100%', clean_text, "对账率不得夸大承诺100%") self.assertNotIn('100% 完整源码', clean_text, "应表述为完整工程源码交付,避免100%绝对词") self.assertNotIn('100% 客户独占', clean_text, "应表述为客户专属独占") self.assertNotIn('100% 覆盖', clean_text, "应表述为核心用例全覆盖") self.assertNotIn('资产 100% 移交', clean_text, "应表述为全套数字资产合规移交") def test_certifications_pragmatic_framing(self): """资质宣传客观严谨,杜绝主观自我标榜'权威资质'""" self.assertNotIn('权威资质背书', self.contents['single_pc'], "应替换为客观严谨的'法定资质认证'") self.assertNotIn('权威资质与软著', self.contents['single_m'], "移动端应同步规范为法定资质与合规资产") if __name__ == '__main__': unittest.main()