1414
1515from __future__ import absolute_import
1616
17+ import pathlib
1718import os
1819import shutil
1920
2223
2324BLACK_VERSION = "black==19.10b0"
2425BLACK_PATHS = ("docs" , "google" , "samples" , "tests" , "noxfile.py" , "setup.py" )
26+ CURRENT_DIRECTORY = pathlib .Path (__file__ ).parent .absolute ()
2527
2628
2729def default (session ):
@@ -32,27 +34,33 @@ def default(session):
3234 Python corresponding to the ``nox`` binary the ``PATH`` can
3335 run the tests.
3436 """
37+ constraints_path = str (
38+ CURRENT_DIRECTORY / "testing" / f"constraints-{ session .python } .txt"
39+ )
40+
3541 # Install all test dependencies, then install local packages in-place.
3642 session .install (
37- "mock" , "pytest" , "google-cloud-testutils" , "pytest-cov" , "freezegun"
43+ "mock" ,
44+ "pytest" ,
45+ "google-cloud-testutils" ,
46+ "pytest-cov" ,
47+ "freezegun" ,
48+ "-c" ,
49+ constraints_path ,
3850 )
39- session .install ("grpcio" )
40-
41- # fastparquet is not included in .[all] because, in general, it's redundant
42- # with pyarrow. We still want to run some unit tests with fastparquet
43- # serialization, though.
44- session .install ("-e" , ".[all,fastparquet]" )
4551
46- # IPython does not support Python 2 after version 5.x
4752 if session .python == "2.7" :
48- session .install ("ipython==5.5" )
53+ # The [all] extra is not installable on Python 2.7.
54+ session .install ("-e" , ".[pandas,pyarrow]" , "-c" , constraints_path )
55+ elif session .python == "3.5" :
56+ session .install ("-e" , ".[all]" , "-c" , constraints_path )
4957 else :
50- session .install ("ipython" )
58+ # fastparquet is not included in .[all] because, in general, it's
59+ # redundant with pyarrow. We still want to run some unit tests with
60+ # fastparquet serialization, though.
61+ session .install ("-e" , ".[all,fastparquet]" , "-c" , constraints_path )
5162
52- # opentelemetry was not added to [all] because opentelemetry does not support Python 2.
53- # Exporter does not need to be in nox thus it has been added to README documentation
54- if session .python != "2.7" :
55- session .install ("-e" , ".[opentelemetry]" )
63+ session .install ("ipython" , "-c" , constraints_path )
5664
5765 # Run py.test against the unit tests.
5866 session .run (
@@ -79,6 +87,10 @@ def unit(session):
7987def system (session ):
8088 """Run the system test suite."""
8189
90+ constraints_path = str (
91+ CURRENT_DIRECTORY / "testing" / f"constraints-{ session .python } .txt"
92+ )
93+
8294 # Check the value of `RUN_SYSTEM_TESTS` env var. It defaults to true.
8395 if os .environ .get ("RUN_SYSTEM_TESTS" , "true" ) == "false" :
8496 session .skip ("RUN_SYSTEM_TESTS is set to false, skipping" )
@@ -88,18 +100,21 @@ def system(session):
88100 session .skip ("Credentials must be set via environment variable." )
89101
90102 # Use pre-release gRPC for system tests.
91- session .install ("--pre" , "grpcio" )
103+ session .install ("--pre" , "grpcio" , "-c" , constraints_path )
92104
93105 # Install all test dependencies, then install local packages in place.
94- session .install ("mock" , "pytest" , "psutil" , "google-cloud-testutils" )
95- session .install ("google-cloud-storage" )
96- session .install ("-e" , ".[all]" )
106+ session .install (
107+ "mock" , "pytest" , "psutil" , "google-cloud-testutils" , "-c" , constraints_path
108+ )
109+ session .install ("google-cloud-storage" , "-c" , constraints_path )
97110
98- # IPython does not support Python 2 after version 5.x
99111 if session .python == "2.7" :
100- session .install ("ipython==5.5" )
112+ # The [all] extra is not installable on Python 2.7.
113+ session .install ("-e" , ".[pandas]" , "-c" , constraints_path )
101114 else :
102- session .install ("ipython" )
115+ session .install ("-e" , ".[all]" , "-c" , constraints_path )
116+
117+ session .install ("ipython" , "-c" , constraints_path )
103118
104119 # Run py.test against the system tests.
105120 session .run (
@@ -111,15 +126,24 @@ def system(session):
111126def snippets (session ):
112127 """Run the snippets test suite."""
113128
129+ constraints_path = str (
130+ CURRENT_DIRECTORY / "testing" / f"constraints-{ session .python } .txt"
131+ )
132+
114133 # Sanity check: Only run snippets tests if the environment variable is set.
115134 if not os .environ .get ("GOOGLE_APPLICATION_CREDENTIALS" , "" ):
116135 session .skip ("Credentials must be set via environment variable." )
117136
118137 # Install all test dependencies, then install local packages in place.
119- session .install ("mock" , "pytest" , "google-cloud-testutils" )
120- session .install ("google-cloud-storage" )
121- session .install ("grpcio" )
122- session .install ("-e" , ".[all]" )
138+ session .install ("mock" , "pytest" , "google-cloud-testutils" , "-c" , constraints_path )
139+ session .install ("google-cloud-storage" , "-c" , constraints_path )
140+ session .install ("grpcio" , "-c" , constraints_path )
141+
142+ if session .python == "2.7" :
143+ # The [all] extra is not installable on Python 2.7.
144+ session .install ("-e" , ".[pandas]" , "-c" , constraints_path )
145+ else :
146+ session .install ("-e" , ".[all]" , "-c" , constraints_path )
123147
124148 # Run py.test against the snippets tests.
125149 # Skip tests in samples/snippets, as those are run in a different session
0 commit comments