|
57 | 57 | import tempfile
|
58 | 58 | import textwrap
|
59 | 59 | import time
|
60 |
| -import unittest |
61 | 60 |
|
62 | 61 | from . import __version__
|
63 | 62 |
|
@@ -637,42 +636,6 @@ def save_next(self):
|
637 | 636 | return filename
|
638 | 637 |
|
639 | 638 |
|
640 |
| -tests_run = 0 |
641 |
| - |
642 |
| -class TestParserPasses(unittest.TestCase): |
643 |
| - directory = "tests/pass" |
644 |
| - |
645 |
| - def filename_test(self, filename): |
646 |
| - b = Blurbs() |
647 |
| - b.load(filename) |
648 |
| - self.assertTrue(b) |
649 |
| - if os.path.exists(filename + '.res'): |
650 |
| - with open(filename + '.res', encoding='utf-8') as file: |
651 |
| - expected = file.read() |
652 |
| - self.assertEqual(str(b), expected) |
653 |
| - |
654 |
| - def test_files(self): |
655 |
| - global tests_run |
656 |
| - with pushd(self.directory): |
657 |
| - for filename in glob.glob("*"): |
658 |
| - if filename[-4:] == '.res': |
659 |
| - self.assertTrue(os.path.exists(filename[:-4]), filename) |
660 |
| - continue |
661 |
| - self.filename_test(filename) |
662 |
| - print(".", end="") |
663 |
| - sys.stdout.flush() |
664 |
| - tests_run += 1 |
665 |
| - |
666 |
| - |
667 |
| -class TestParserFailures(TestParserPasses): |
668 |
| - directory = "tests/fail" |
669 |
| - |
670 |
| - def filename_test(self, filename): |
671 |
| - b = Blurbs() |
672 |
| - with self.assertRaises(Exception): |
673 |
| - b.load(filename) |
674 |
| - |
675 |
| - |
676 | 639 | readme_re = re.compile(r"This is \w+ version \d+\.\d+").match
|
677 | 640 |
|
678 | 641 | def chdir_to_repo_root():
|
@@ -836,36 +799,6 @@ def _find_blurb_dir():
|
836 | 799 | return None
|
837 | 800 |
|
838 | 801 |
|
839 |
| -@subcommand |
840 |
| -def test(*args): |
841 |
| - """ |
842 |
| -Run unit tests. Only works inside source repo, not when installed. |
843 |
| - """ |
844 |
| - # unittest.main doesn't work because this isn't a module |
845 |
| - # so we'll do it ourselves |
846 |
| - |
847 |
| - while (blurb_dir := _find_blurb_dir()) is None: |
848 |
| - old_dir = os.getcwd() |
849 |
| - os.chdir("..") |
850 |
| - if old_dir == os.getcwd(): |
851 |
| - # we reached the root and never found it! |
852 |
| - sys.exit("Error: Couldn't find the root of your blurb repo!") |
853 |
| - os.chdir(blurb_dir) |
854 |
| - |
855 |
| - print("-" * 79) |
856 |
| - |
857 |
| - for clsname, cls in sorted(globals().items()): |
858 |
| - if clsname.startswith("Test") and isinstance(cls, type): |
859 |
| - o = cls() |
860 |
| - for fnname in sorted(dir(o)): |
861 |
| - if fnname.startswith("test"): |
862 |
| - fn = getattr(o, fnname) |
863 |
| - if callable(fn): |
864 |
| - fn() |
865 |
| - print() |
866 |
| - print(tests_run, "tests passed.") |
867 |
| - |
868 |
| - |
869 | 802 | def find_editor():
|
870 | 803 | for var in 'GIT_EDITOR', 'EDITOR':
|
871 | 804 | editor = os.environ.get(var)
|
@@ -1222,7 +1155,7 @@ def main():
|
1222 | 1155 | fn = get_subcommand(subcommand)
|
1223 | 1156 |
|
1224 | 1157 | # hack
|
1225 |
| - if fn in (help, test, version): |
| 1158 | + if fn in (help, version): |
1226 | 1159 | sys.exit(fn(*args))
|
1227 | 1160 |
|
1228 | 1161 | try:
|
|
0 commit comments