8000 Allow running blurb test from blurb-* directories · python/blurb@984c4d2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 984c4d2

Browse files
committed
Allow running blurb test from blurb-* directories
Fixes #21
1 parent 40fd999 commit 984c4d2

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/blurb/blurb.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ def save_next(self):
642642
tests_run = 0
643643

644644
class TestParserPasses(unittest.TestCase):
645-
directory = "blurb/tests/pass"
645+
directory = "tests/pass"
646646

647647
def filename_test(self, filename):
648648
b = Blurbs()
@@ -667,7 +667,7 @@ def test_files(self):
667667

668668

669669
class TestParserFailures(TestParserPasses):
670-
directory = "blurb/tests/fail"
670+
directory = "tests/fail"
671671

672672
def filename_test(self, filename):
673673
b = Blurbs()
@@ -820,6 +820,15 @@ def help(subcommand=None):
820820
subcommands["--help"] = help
821821

822822

823+
def _find_blurb_dir():
824+
if os.path.isdir("blurb"):
825+
return "blurb"
826+
for path in glob.iglob("blurb-*"):
827+
if os.path.isdir(path):
828+
return path
829+
return None
830+
831+
823832
@subcommand
824833
def test(*args):
825834
"""
@@ -828,12 +837,13 @@ def test(*args):
828837
# unittest.main doesn't work because this isn't a module
829838
# so we'll do it ourselves
830839

831-
while not os.path.isdir("blurb"):
840+
while (blurb_dir := _find_blurb_dir()) is None:
832841
old_dir = os.getcwd()
833842
os.chdir("..")
834843
if old_dir == os.getcwd():
835844
# we reached the root and never found it!
836845
sys.exit("Error: Couldn't find the root of your blurb repo!")
846+
os.chdir(blurb_dir)
837847

838848
print("-" * 79)
839849

0 commit comments

Comments
 (0)
0