coding-alt/AutoGPT
0
1import os2import sys3import unittest4 5from bs4 import BeautifulSoup6 7sys.path.append(os.path.abspath("../scripts"))8 9from browse import extract_hyperlinks10 11 12class TestBrowseLinks(unittest.TestCase):13 def test_extract_hyperlinks(self):14 body = """15 <body>16 <a href="https://google.com">Google</a>17 <a href="foo.html">Foo</a>18 <div>Some other crap</div>19 </body>20 """21 soup = BeautifulSoup(body, "html.parser")22 links = extract_hyperlinks(soup, "http://example.com")23 self.assertEqual(24 links,25 [("Google", "https://google.com"), ("Foo", "http://example.com/foo.html")],26 )27 