Product 1
+Description 1
+diff --git a/tests/parser/test_automatch.py b/tests/parser/test_automatch.py index 79fe6b7..38ad88b 100644 --- a/tests/parser/test_automatch.py +++ b/tests/parser/test_automatch.py @@ -1,10 +1,11 @@ -import unittest +import asyncio + +import pytest from scrapling import Adaptor -class TestParserAutoMatch(unittest.TestCase): - +class TestParserAutoMatch: def test_element_relocation(self): """Test relocating element after structure change""" original_html = ''' @@ -50,7 +51,61 @@ class TestParserAutoMatch(unittest.TestCase): _ = old_page.css('#p1, #p2', auto_save=True)[0] relocated = new_page.css('#p1', auto_match=True) - self.assertIsNotNone(relocated) - self.assertEqual(relocated[0].attrib['data-id'], 'p1') - self.assertTrue(relocated[0].has_class('new-class')) - self.assertEqual(relocated[0].css('.new-description')[0].text, 'Description 1') + assert relocated is not None + assert relocated[0].attrib['data-id'] == 'p1' + assert relocated[0].has_class('new-class') + assert relocated[0].css('.new-description')[0].text == 'Description 1' + + @pytest.mark.asyncio + async def test_element_relocation_async(self): + """Test relocating element after structure change in async mode""" + original_html = ''' +
Description 1
+Description 2
+Description 1
+Description 2
+