Skip to content

Instantly share code, notes, and snippets.

@edsu
Last active October 1, 2021 22:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edsu/d673b3c5cbfb666089cc2de238a8b5d0 to your computer and use it in GitHub Desktop.
Save edsu/d673b3c5cbfb666089cc2de238a8b5d0 to your computer and use it in GitHub Desktop.
Who tests the test testers?
#!/usr/bin/env python3
import re
import sys
import pytest
import shutil
import pathlib
name = sys.argv[1]
work = pathlib.Path('.')
mfile, tfile = [f for f in sorted(work.iterdir()) if re.match(name, f.name)]
# convert uploaded filename to the filename that should be imported
module_file = re.sub(r'.+_question_\d+_\d+_(.+)$', r'\1', mfile.name)
shutil.copyfile(mfile, module_file)
print()
print(f"module_file: {module_file}")
print(f"test file: {tfile.name}")
print()
pytest.main([tfile.name])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment