def test_TldMatcher():
    matcher = TldMatcher()
test_urls = ['site.co.uk', 'site.com', 'site.me.uk', 'site.jpn.com',
    'site.org.uk', 'site.it']
errors = 0
for u in test_urls:
    res = matcher.get2ld(u)
if res != 'site':
    print("Error: found '{0}', should be 'site'".format(res))
errors += 1
if errors == 0:
    print('Passed!')
return errors == 0
Extract 2nd level domain from domain? - Python