14
14
15
15
from __future__ import absolute_import
16
16
17
+ import pathlib
17
18
import os
18
19
import shutil
19
20
22
23
23
24
BLACK_VERSION = "black==19.10b0"
24
25
BLACK_PATHS = ("docs" , "google" , "samples" , "tests" , "noxfile.py" , "setup.py" )
26
+ CURRENT_DIRECTORY = pathlib .Path (__file__ ).parent .absolute ()
25
27
26
28
27
29
def default (session ):
@@ -32,27 +34,33 @@ def default(session):
32
34
Python corresponding to the ``nox`` binary the ``PATH`` can
33
35
run the tests.
34
36
"""
37
+ constraints_path = str (
38
+ CURRENT_DIRECTORY / "testing" / f"constraints-{ session .python } .txt"
39
+ )
40
+
35
41
# Install all test dependencies, then install local packages in-place.
36
42
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 ,
38
50
)
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]" )
45
51
46
- # IPython does not support Python 2 after version 5.x
47
52
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 )
49
57
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 )
51
62
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 )
56
64
57
65
# Run py.test against the unit tests.
58
66
session .run (
@@ -79,6 +87,10 @@ def unit(session):
79
87
def system (session ):
80
88
"""Run the system test suite."""
81
89
90
+ constraints_path = str (
91
+ CURRENT_DIRECTORY / "testing" / f"constraints-{ session .python } .txt"
92
+ )
93
+
82
94
# Check the value of `RUN_SYSTEM_TESTS` env var. It defaults to true.
83
95
if os .environ .get ("RUN_SYSTEM_TESTS" , "true" ) == "false" :
84
96
session .skip ("RUN_SYSTEM_TESTS is set to false, skipping" )
@@ -88,18 +100,21 @@ def system(session):
88
100
session .skip ("Credentials must be set via environment variable." )
89
101
90
102
# Use pre-release gRPC for system tests.
91
- session .install ("--pre" , "grpcio" )
103
+ session .install ("--pre" , "grpcio" , "-c" , constraints_path )
92
104
93
105
# 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 )
97
110
98
- # IPython does not support Python 2 after version 5.x
99
111
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 )
101
114
else :
102
- session .install ("ipython" )
115
+ session .install ("-e" , ".[all]" , "-c" , constraints_path )
116
+
117
+ session .install ("ipython" , "-c" , constraints_path )
103
118
104
119
# Run py.test against the system tests.
105
120
session .run (
@@ -111,15 +126,24 @@ def system(session):
111
126
def snippets (session ):
112
127
"""Run the snippets test suite."""
113
128
129
+ constraints_path = str (
130
+ CURRENT_DIRECTORY / "testing" / f"constraints-{ session .python } .txt"
131
+ )
132
+
114
133
# Sanity check: Only run snippets tests if the environment variable is set.
115
134
if not os .environ .get ("GOOGLE_APPLICATION_CREDENTIALS" , "" ):
116
135
session .skip ("Credentials must be set via environment variable." )
117
136
118
137
# 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 )
123
147
124
148
# Run py.test against the snippets tests.
125
149
# Skip tests in samples/snippets, as those are run in a different session
0 commit comments