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