Fix tests to work with newest version of pytype (#1824)

This commit is contained in:
Matthias Kramm
2018-01-12 12:28:19 -08:00
committed by GitHub
parent 5264fa6d5d
commit 72052d8338

View File

@@ -60,19 +60,23 @@ def load_blacklist():
class BinaryRun(object):
def __init__(self, args, dry_run=False):
def __init__(self, args, dry_run=False, env=None):
self.args = args
self.dry_run = dry_run
self.results = None
if dry_run:
self.results = (0, '', '')
else:
if env is not None:
full_env = os.environ.copy()
full_env.update(env)
else:
full_env = None
self.proc = subprocess.Popen(
self.args,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stderr=subprocess.PIPE,
env=full_env)
def communicate(self):
if self.results:
@@ -122,11 +126,11 @@ def pytype_test(args):
if f in pytype_run:
test_run = BinaryRun(
['pytype',
'--typeshed-location=%s' % os.getcwd(),
'--module-name=%s' % _get_module_name(f),
'--convert-to-pickle=%s' % os.devnull,
'--parse-pyi',
f],
dry_run=args.dry_run)
dry_run=args.dry_run,
env={"TYPESHED_HOME": os.getcwd()})
elif f in pytd_run:
test_run = BinaryRun(['pytd', f], dry_run=args.dry_run)
else: