3030"""
3131
3232import fnmatch
33- import itertools
3433import os
3534import subprocess
3635import tempfile
4645 '-x' , '--no-success-flaky-report' , '--cov' , '--cov-config' ,
4746 '.coveragerc' , '--cov-append' , '--cov-report=' ]
4847
49- # Blacklists of samples to ingnore.
50- # Bigtable and Speech are disabled because they use gRPC, which does not yet
51- # support Python 3. See: https://github.com/grpc/grpc/issues/282
52- TESTS_BLACKLIST = set ((
53- './appengine/standard' ,
54- './bigtable' ,
55- './speech' ,
56- './testing' ))
57- APPENGINE_BLACKLIST = set ()
58-
5948
6049# Libraries that only work on Python 2.7
6150PY27_ONLY_LIBRARIES = ['mysql-python' ]
@@ -132,8 +121,11 @@ def filter_samples(sample_dirs, changed_files):
132121def setup_appengine (session ):
133122 """Installs the App Engine SDK."""
134123 # Install the app engine sdk and setup import paths.
124+ if session .interpreter .startswith ('python3' ):
125+ return
126+
135127 gae_root = os .environ .get ('GAE_ROOT' , tempfile .gettempdir ())
136- session .env ['PYTHONPATH ' ] = os .path .join (gae_root , 'google_appengine' )
128+ session .env ['GAE_SDK_PATH ' ] = os .path .join (gae_root , 'google_appengine' )
137129 session .run ('gcprepotools' , 'download-appengine-sdk' , gae_root )
138130
139131 # Create a lib directory to prevent the GAE vendor library from
@@ -143,8 +135,8 @@ def setup_appengine(session):
143135
144136
145137def run_tests_in_sesssion (
146- session , interpreter , use_appengine = False , skip_flaky = False ,
147- changed_only = False , sample_directories = None ):
138+ session , interpreter , sample_directories , use_appengine = True ,
139+ skip_flaky = False , changed_only = False ):
148140 """This is the main function for executing tests.
149141
150142 It:
@@ -173,13 +165,6 @@ def run_tests_in_sesssion(
173165 if skip_flaky :
174166 pytest_args .append ('-m not slow and not flaky' )
175167
176- # session.posargs is any leftover arguments from the command line,
177- # which allows users to run a particular test instead of all of them.
178- if session .posargs :
179- sample_directories = session .posargs
180- elif sample_directories is None :
181- sample_directories = collect_sample_dirs ('.' , TESTS_BLACKLIST )
182-
183168 if changed_only :
184169 changed_files = get_changed_files ()
185170 sample_directories = filter_samples (
@@ -204,43 +189,38 @@ def run_tests_in_sesssion(
204189
205190@nox .parametrize ('interpreter' , ['python2.7' , 'python3.4' ])
206191def session_tests (session , interpreter ):
207- """Runs tests"""
208- run_tests_in_sesssion (session , interpreter )
209-
192+ """Runs tests for all non-gae standard samples."""
193+ # session.posargs is any leftover arguments from the command line,
194+ # which allows users to run a particular test instead of all of them.
195+ sample_directories = session .posargs
196+ if not sample_directories :
197+ sample_directories = collect_sample_dirs ('.' )
210198
211- def session_gae (session ):
212- """Runs test for GAE Standard samples."""
213199 run_tests_in_sesssion (
214- session , 'python2.7' , use_appengine = True ,
215- sample_directories = collect_sample_dirs (
216- 'appengine/standard' ,
217- APPENGINE_BLACKLIST ))
200+ session , interpreter , sample_directories )
218201
219202
220- def session_grpc (session ):
221- """Runs tests for samples that need grpc ."""
222- # TODO: Remove this when grpc supports Python 3.
203+ def session_gae (session ):
204+ """Runs test for GAE Standard samples ."""
205+ sample_directories = collect_sample_dirs ( 'appengine/standard' )
223206 run_tests_in_sesssion (
224- session ,
225- 'python2.7' ,
226- sample_directories = itertools .chain (
227- collect_sample_dirs ('speech' ),
228- collect_sample_dirs ('bigtable' )))
207+ session , 'python2.7' , sample_directories , use_appengine = True )
229208
230209
231210@nox .parametrize ('subsession' , ['gae' , 'tests' ])
232211def session_travis (session , subsession ):
233212 """On travis, just run with python3.4 and don't run slow or flaky tests."""
234213 if subsession == 'tests' :
214+ sample_directories = collect_sample_dirs (
215+ '.' , set ('./appengine/standard' ))
235216 run_tests_in_sesssion (
236- session , 'python3.4' , skip_flaky = True , changed_only = True )
217+ session , 'python3.4' , sample_directories ,
218+ skip_flaky = True , changed_only = True )
237219 else :
220+ sample_directories = collect_sample_dirs ('appengine/standard' )
238221 run_tests_in_sesssion (
239- session , 'python2.7' , use_appengine = True , skip_flaky = True ,
240- changed_only = True ,
241- sample_directories = collect_sample_dirs (
242- 'appengine/standard' ,
243- APPENGINE_BLACKLIST ))
222+ session , 'python2.7' , sample_directories ,
223+ skip_flaky = True , changed_only = True )
244224
245225
246226def session_lint (session ):
0 commit comments