Skip to content

IndexError: list index out of range #139

@CachingFoX

Description

@CachingFoX

If I run test cases with python setup.py lint I got an IndexError: list index out of range exception. The repository is up-to-date and without any changes. This appends since some days.

======================================================================
ERROR: test_get_cache (test.test_geocaching.TestShortcuts)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/andreas/PycharmProjects/pycaching_dev/test/test_geocaching.py", line 393, in test_get_cache
    self.assertEqual("Nekonecne ticho", c.name)
  File "/Users/andreas/PycharmProjects/pycaching_dev/pycaching/util.py", line 31, in wrapper
    self.load()
  File "/Users/andreas/PycharmProjects/pycaching_dev/pycaching/cache.py", line 741, in load
    self._logbook_token = re.findall("userToken\\s*=\\s*'([^']+)'", js_content)[0]
IndexError: list index out of range

I have debug the exception and I found following problem and a "solution":
js_content = "\n".join(map(lambda i: i.text, root.find_all("script")))

  • js_content is full of newlines
  • root.find_all("script") is okay
  • map returns a empty set - I don't know way

Solution
I use a virtual environment and I down-grade the package beautifulsoup4 from version 4.9.0 to 4.8.2 and it works.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions