Skip to content

Commit 1f58f46

Browse files
committed
Updates Python script to not fail if empty list
1 parent 4d7c85d commit 1f58f46

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

lib/insert_contributor_content.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,12 @@ def build_markdown_content(
150150
:param stargazers: The list of stargazers of the repository.
151151
:return: The markdown content to be inserted into the README.
152152
"""
153-
md_content = "User | Contribution\n---|---\n"
154153

154+
if not contributors:
155+
logger.info(f"No contributors found yet, cancelling markdown generation")
156+
return ""
157+
158+
md_content = "User | Contribution\n---|---\n"
155159
for contributor in contributors:
156160
username = contributor["username"]
157161
question = contributor["question"]

lib/tests/run_all_tests.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import unittest
2+
import os
3+
4+
# Get the directory where the script is located
5+
current_directory = os.path.dirname(os.path.abspath(__file__))
26

3-
# Discover and run all tests in the current directory and its subdirectories.
47
if __name__ == "__main__":
58
test_loader = unittest.TestLoader()
6-
test_suite = test_loader.discover(start_dir='.', pattern='test_*.py')
9+
# Set the start directory to the directory of this script
10+
test_suite = test_loader.discover(start_dir=current_directory, pattern='test_*.py')
711
test_runner = unittest.TextTestRunner(verbosity=2)
812
test_runner.run(test_suite)

0 commit comments

Comments
 (0)