-
-
Save tigarmo/e93ee0984bc714e9b875 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import fnmatch | |
import sys | |
import subprocess | |
directory = sys.argv[1] | |
for root, dirs, names in os.walk(sys.argv[1]): | |
for name in names: | |
if fnmatch.fnmatch(name, 'pytest_*.py') and os.path.basename(root) == '_tests': | |
source = os.path.join(root, name) | |
target = os.path.join(root, name[2:]) | |
if not os.path.isfile(target): | |
data_dir = os.path.splitext(source)[0] | |
if os.path.isdir(data_dir): | |
dir_name = os.path.basename(data_dir)[2:] | |
target_dir = os.path.join(os.path.dirname(data_dir), dir_name) | |
subprocess.call('git mv %s %s' % (data_dir, target_dir)) | |
subprocess.call('git mv %s %s' % (source, target)) | |
else: | |
print '***', target, 'already exists: merge the two tests' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment