petermr / amiclimate

software and material for managing climate knowledge
Apache License 2.0
0 stars 0 forks source link

test/test_un.py::TestIPCC::test_ipcc_syr_lr_toc_full - IndexError #9

Open flower1430 opened 4 months ago

flower1430 commented 4 months ago
"C:\Program Files\Python39\python.exe" "C:/Program Files/JetBrains/PyCharm Community Edition 2023.2.5/plugins/python-ce/helpers/pycharm/_jb_pytest_runner.py" --target test_un.py::TestIPCC.test_ipcc_syr_lr_toc_full 
Testing started at 10:35 AM ...
Launching pytest with arguments test_un.py::TestIPCC::test_ipcc_syr_lr_toc_full --no-header --no-summary -q in C:\Users\ADMIN\Desktop\sc_pyami\amiclimate\test

============================= test session starts =============================
collecting ... collected 1 item

test_un.py::TestIPCC::test_ipcc_syr_lr_toc_full 

============================== 1 failed in 4.79s ==============================
FAILED                   [100%]
test\test_un.py:1250 (TestIPCC.test_ipcc_syr_lr_toc_full)
self = <test.test_un.TestIPCC testMethod=test_ipcc_syr_lr_toc_full>

    def test_ipcc_syr_lr_toc_full(self):
        """creates toc recursively for IPCC syr longer report
        """
        filename = HTML_WITH_IDS_HTML
        syr_lr_content = Path(Resources.TEST_RESOURCES_DIR, IPCC_DIR, CLEANED_CONTENT, SYR,
                              SYR_LR, filename)
        lr_html = ET.parse(str(syr_lr_content), HTMLParser())
        body = HtmlLib.get_body(lr_html)
        publisher = IPCCGatsby()
        toc_html, ul = publisher.make_header_and_nav_ul(body)
        level = 0
>       publisher.analyse_containers(body, level, ul, filename=filename)

test_un.py:1262: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
..\climate\ipcc.py:1346: in analyse_containers
    self.add_container_infp_to_tree(debug, filename, h_container, level, texts, ul)
..\climate\ipcc.py:1364: in add_container_infp_to_tree
    self.analyse_containers(h_container, level + 1, ul1, filename=filename)
..\climate\ipcc.py:1346: in analyse_containers
    self.add_container_infp_to_tree(debug, filename, h_container, level, texts, ul)
..\climate\ipcc.py:1364: in add_container_infp_to_tree
    self.analyse_containers(h_container, level + 1, ul1, filename=filename)
..\climate\ipcc.py:1346: in analyse_containers
    self.add_container_infp_to_tree(debug, filename, h_container, level, texts, ul)
..\climate\ipcc.py:1364: in add_container_infp_to_tree
    self.analyse_containers(h_container, level + 1, ul1, filename=filename)
..\climate\ipcc.py:1346: in analyse_containers
    self.add_container_infp_to_tree(debug, filename, h_container, level, texts, ul)
..\climate\ipcc.py:1364: in add_container_infp_to_tree
    self.analyse_containers(h_container, level + 1, ul1, filename=filename)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <climate.ipcc.IPCCGatsby object at 0x000001E37AB18F10>
container = <Element div at 0x1e37ab2dd60>, level = 4
ul = <Element ul at 0x1e37ab20600>, filename = 'html_with_ids.html'
debug = False

    def analyse_containers(self, container, level, ul, filename=None, debug=False):
        """Part of ToC making"""
>       container_xpath = f".//div[contains(@class,'{self.container_levels[level]}')]"
E       IndexError: list index out of range

..\climate\ipcc.py:1341: IndexError

Process finished with exit code 1
petermr commented 4 months ago

This depends on the precise content of the file and needs to be manually investigated. Hopefully it can be ignored

On Tue, May 14, 2024 at 6:07 AM flower1430 @.***> wrote:

"C:\Program Files\Python39\python.exe" "C:/Program Files/JetBrains/PyCharm Community Edition 2023.2.5/plugins/python-ce/helpers/pycharm/_jb_pytest_runner.py" --target test_un.py::TestIPCC.test_ipcc_syr_lr_toc_full Testing started at 10:35 AM ... Launching pytest with arguments test_un.py::TestIPCC::test_ipcc_syr_lr_toc_full --no-header --no-summary -q in C:\Users\ADMIN\Desktop\sc_pyami\amiclimate\test

============================= test session starts ============================= collecting ... collected 1 item

test_un.py::TestIPCC::test_ipcc_syr_lr_toc_full

============================== 1 failed in 4.79s ============================== FAILED [100%] test\test_un.py:1250 (TestIPCC.test_ipcc_syr_lr_toc_full) self =

def test_ipcc_syr_lr_toc_full(self):
    """creates toc recursively for IPCC syr longer report
    """
    filename = HTML_WITH_IDS_HTML
    syr_lr_content = Path(Resources.TEST_RESOURCES_DIR, IPCC_DIR, CLEANED_CONTENT, SYR,
                          SYR_LR, filename)
    lr_html = ET.parse(str(syr_lr_content), HTMLParser())
    body = HtmlLib.get_body(lr_html)
    publisher = IPCCGatsby()
    toc_html, ul = publisher.make_header_and_nav_ul(body)
    level = 0
  publisher.analyse_containers(body, level, ul, filename=filename)

test_un.py:1262:


..\climate\ipcc.py:1346: in analyse_containers self.add_container_infp_to_tree(debug, filename, h_container, level, texts, ul) ..\climate\ipcc.py:1364: in add_container_infp_to_tree self.analyse_containers(h_container, level + 1, ul1, filename=filename) ..\climate\ipcc.py:1346: in analyse_containers self.add_container_infp_to_tree(debug, filename, h_container, level, texts, ul) ..\climate\ipcc.py:1364: in add_container_infp_to_tree self.analyse_containers(h_container, level + 1, ul1, filename=filename) ..\climate\ipcc.py:1346: in analyse_containers self.add_container_infp_to_tree(debug, filename, h_container, level, texts, ul) ..\climate\ipcc.py:1364: in add_container_infp_to_tree self.analyse_containers(h_container, level + 1, ul1, filename=filename) ..\climate\ipcc.py:1346: in analyse_containers self.add_container_infp_to_tree(debug, filename, h_container, level, texts, ul) ..\climate\ipcc.py:1364: in add_container_infp_to_tree self.analyse_containers(h_container, level + 1, ul1, filename=filename)


self = <climate.ipcc.IPCCGatsby object at 0x000001E37AB18F10> container = <Element div at 0x1e37ab2dd60>, level = 4 ul = <Element ul at 0x1e37ab20600>, filename = 'html_with_ids.html' debug = False

def analyse_containers(self, container, level, ul, filename=None, debug=False):
    """Part of ToC making"""
  container_xpath = ***@***.***,'{self.container_levels[level]}')]"

E IndexError: list index out of range

..\climate\ipcc.py:1341: IndexError

Process finished with exit code 1

— Reply to this email directly, view it on GitHub https://github.com/petermr/amiclimate/issues/9, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFTCSYWBB7FDCNJZJ33IFDZCGL2LAVCNFSM6AAAAABHVNQCW6VHI2DSMVQWIX3LMV43ASLTON2WKOZSGI4TINBRGY2DANQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- Peter Murray-Rust Founder ContentMine.org and Reader Emeritus in Molecular Informatics Dept. Of Chemistry, University of Cambridge, CB2 1EW, UK

xpriyanshux commented 4 months ago

getting the same error on windows 11 Python 3.10.11