Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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)'git mv %s %s' % (data_dir, target_dir))'git mv %s %s' % (source, target))
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