diff --git a/tests/test_snippets/test_adventures.py b/tests/test_snippets/test_adventures.py index 9e8c9fb4aa7..0930513185e 100644 --- a/tests/test_snippets/test_adventures.py +++ b/tests/test_snippets/test_adventures.py @@ -77,25 +77,25 @@ def collect_snippets(path, filtered_language=None): # Code snippets inside example code try: example_code = utils.markdown_to_html_tags(level['example_code']) + for tag in example_code: + if tag.name != 'pre' or not tag.contents[0]: + continue + code_snippet_counter += 1 + try: + code = tag.contents[0].contents[0] + except BaseException: + print("Code container is empty...") + continue + + snippet = Snippet( + filename=f, + level=level_number, + field_name=adventure_name + ' snippet #' + str(code_snippet_counter), + code=code, + adventure_name=adventure_name) + Hedy_snippets.append(snippet) except Exception as E: print(E) - for tag in example_code: - if tag.name != 'pre' or not tag.contents[0]: - continue - code_snippet_counter += 1 - try: - code = tag.contents[0].contents[0] - except BaseException: - print("Code container is empty...") - continue - - snippet = Snippet( - filename=f, - level=level_number, - field_name=adventure_name + ' snippet #' + str(code_snippet_counter), - code=code, - adventure_name=adventure_name) - Hedy_snippets.append(snippet) return Hedy_snippets @@ -106,7 +106,7 @@ def collect_snippets(path, filtered_language=None): Hedy_snippets = [(s.name, s) for s in collect_snippets(path='../../content/adventures', filtered_language=filtered_language)] # -# level = 3 +# level = 4 if level: Hedy_snippets = [(name, snippet) for (name, snippet) in Hedy_snippets if snippet.level == level]