예제 #1
0
파일: test_main.py 프로젝트: thy97/pakku.js
runner.set_global_switch(False)
runner.b.get('http://www.bilibili.com/favicon.ico')
time.sleep(.5) # wait for ajax hook
assert '[x' not in runner.parse_ajax(EXAMPLE_DANMAKU)

runner.set_global_switch(True)
runner.b.get('http://www.bilibili.com/favicon.ico')
time.sleep(.5) # wait for ajax hook
assert '[x' in runner.parse_ajax(EXAMPLE_DANMAKU)
assert '[x' not in runner.parse_ajax(EXAMPLE_DANMAKU+'?pakku_test')
'''

print('!= test working')

danmus = runner.parse_string(demo('unicode'))
assert len(danmus) == 1
assert danmus[0].childNodes[0].data == 'testtest[]【】'
assert len(runner.parse_string(demo('different_100'))) == 100

print('!= test danmu mark')

runner.update_settings('DANMU_MARK', 'off')
assert runner.parse_string(
    demo('unicode_2'))[0].childNodes[0].data == 'testtest[]【】'
runner.update_settings('DANMU_MARK', 'suffix')
assert runner.parse_string(
    demo('unicode_2'))[0].childNodes[0].data == 'testtest[]【】[x2]'
runner.update_settings('DANMU_MARK', 'prefix')
assert runner.parse_string(
    demo('unicode_2'))[0].childNodes[0].data == '[x2]testtest[]【】'
예제 #2
0
print('!= test xml format')

src = runner.get_source()
dom = parseString(src)

assert len(dom.childNodes) == 1
assert dom.childNodes[0].tagName == 'i'
danmu = dom.getElementsByTagName('d')[0]
assert len(danmu.getAttribute('p').split(',')) > 3
assert len(danmu.childNodes) == 1
assert isinstance(danmu.childNodes[0], Text)

print('!= test encoding')

danmus = runner.parse_string(demo('unicode'))
assert len(danmus) == 1
assert danmus[0].childNodes[0].data == 'testtest[]【】'

print('!= test danmu mark')

runner.update_settings('DANMU_MARK', 'off')
assert runner.parse_string(
    demo('unicode_2'))[0].childNodes[0].data == 'testtest[]【】'
runner.update_settings('DANMU_MARK', 'suffix')
assert runner.parse_string(
    demo('unicode_2'))[0].childNodes[0].data == 'testtest[]【】 [x2]'
runner.update_settings('DANMU_MARK', 'prefix')
assert runner.parse_string(
    demo('unicode_2'))[0].childNodes[0].data == '[x2] testtest[]【】'