Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow running blurb test from blurb-* directories #24

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Allow running blurb test from blurb-* directories
Fixes #21
  • Loading branch information
hroncok committed Jul 22, 2024
commit 984c4d21f8c7a74ce44c3c0b832859ac7de12e1b
16 changes: 13 additions & 3 deletions src/blurb/blurb.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@
tests_run = 0

class TestParserPasses(unittest.TestCase):
directory = "blurb/tests/pass"
directory = "tests/pass"

def filename_test(self, filename):
b = Blurbs()
Expand All @@ -667,7 +667,7 @@


class TestParserFailures(TestParserPasses):
directory = "blurb/tests/fail"
directory = "tests/fail"

def filename_test(self, filename):
b = Blurbs()
Expand Down Expand Up @@ -820,6 +820,15 @@
subcommands["--help"] = help


def _find_blurb_dir():
if os.path.isdir("blurb"):
return "blurb"
for path in glob.iglob("blurb-*"):
if os.path.isdir(path):
return path
return None

Check warning on line 829 in src/blurb/blurb.py

View check run for this annotation

Codecov / codecov/patch

src/blurb/blurb.py#L824-L829

Added lines #L824 - L829 were not covered by tests


@subcommand
def test(*args):
"""
Expand All @@ -828,12 +837,13 @@
# unittest.main doesn't work because this isn't a module
# so we'll do it ourselves

while not os.path.isdir("blurb"):
while (blurb_dir := _find_blurb_dir()) is None:

Check warning on line 840 in src/blurb/blurb.py

View check run for this annotation

Codecov / codecov/patch

src/blurb/blurb.py#L840

Added line #L840 was not covered by tests
old_dir = os.getcwd()
os.chdir("..")
if old_dir == os.getcwd():
# we reached the root and never found it!
sys.exit("Error: Couldn't find the root of your blurb repo!")
os.chdir(blurb_dir)

Check warning on line 846 in src/blurb/blurb.py

View check run for this annotation

Codecov / codecov/patch

src/blurb/blurb.py#L846

Added line #L846 was not covered by tests

print("-" * 79)

Expand Down