def test_blocking_with_whitelist(config_stub, basedir, download_stub, data_tmpdir, tmpdir):
 filtered_blocked_hosts = BLOCKLIST_HOSTS[1:]
 blocklist = create_blocklist(data_tmpdir, blocked_hosts=filtered_blocked_hosts, name='blocked-hosts', line_format='one_per_line')
 config_stub.data = {'content': {'host-block-lists': [blocklist], 'host-blocking-enabled': True, 'host-blocking-whitelist': WHITELISTED_HOSTS}}
 host_blocker = adblock.HostBlocker()
 host_blocker.read_hosts()
 assert_urls(host_blocker)

def test_blocking_with_whitelist ( config_stub , basedir , download_stub , data_tmpdir , tmpdir ) : filtered_blocked_hosts = BLOCKLIST_HOSTS [ 1 : ] blocklist = create_blocklist ( data_tmpdir , blocked_hosts = filtered_blocked_hosts , name = 'blocked-hosts' , line_format = 'one_per_line' ) config_stub . data = { 'content' : { 'host-block-lists' : [ blocklist ] , 'host-blocking-enabled' : True , 'host-blocking-whitelist' : WHITELISTED_HOSTS } } host_blocker = adblock . HostBlocker ( ) host_blocker . read_hosts ( ) assert_urls ( host_blocker )
ensure hosts in host-blocking-whitelist are never blocked .