2020import nox
2121
2222
23- LOCAL_DEPS = (os .path .join (".." , "api_core" ),)
23+ LOCAL_DEPS = (os .path .join (".." , "api_core" ), os .path .join (".." , "core" ))
24+
25+ @nox .session (python = "3.7" )
26+ def blacken (session ):
27+ """Run black.
28+
29+ Format code to uniform standard.
30+ """
31+ session .install ("black" )
32+ session .run (
33+ "black" ,
34+ "google" ,
35+ "tests" ,
36+ "docs" ,
37+ "--exclude" ,
38+ ".*/proto/.*|.*/gapic/.*|.*/.*_pb2.py" ,
39+ )
40+
41+
42+ @nox .session (python = "3.7" )
43+ def lint (session ):
44+ """Run linters.
45+
46+ Returns a failure if the linters find linting errors or sufficiently
47+ serious code quality issues.
48+ """
49+ session .install ("flake8" , "black" , * LOCAL_DEPS )
50+ session .run (
51+ "black" ,
52+ "--check" ,
53+ "google" ,
54+ "tests" ,
55+ "docs" ,
56+ "--exclude" ,
57+ ".*/proto/.*|.*/gapic/.*|.*/.*_pb2.py" ,
58+ )
59+ session .run ("flake8" , "google" , "tests" )
60+
61+
62+ @nox .session (python = "3.7" )
63+ def lint_setup_py (session ):
64+ """Verify that setup.py is valid (including RST check)."""
65+ session .install ("docutils" , "pygments" )
66+ session .run ("python" , "setup.py" , "check" , "--restructuredtext" , "--strict" )
2467
2568
2669def default (session ):
@@ -39,7 +82,7 @@ def default(session):
3982 "--cov-append" ,
4083 "--cov-config=.coveragerc" ,
4184 "--cov-report=" ,
42- "--cov-fail-under=86 " ,
85+ "--cov-fail-under=79 " ,
4386 os .path .join ("tests" , "unit" ),
4487 * session .posargs ,
4588 )
@@ -55,11 +98,15 @@ def unit(session):
5598def system (session ):
5699 """Run the system test suite."""
57100 system_test_path = os .path .join ("tests" , "system.py" )
101+ system_test_folder_path = os .path .join ("tests" , "system" )
58102 # Sanity check: Only run tests if the environment variable is set.
59103 if not os .environ .get ("GOOGLE_APPLICATION_CREDENTIALS" , "" ):
60104 session .skip ("Credentials must be set via environment variable" )
105+
106+ system_test_exists = os .path .exists (system_test_path )
107+ system_test_folder_exists = os .path .exists (system_test_folder_path )
61108 # Sanity check: only run tests if found.
62- if not os . path . exists ( system_test_path ) :
109+ if not system_test_exists and not system_test_folder_exists :
63110 session .skip ("System tests were not found" )
64111
65112 # Use pre-release gRPC for system tests.
@@ -74,52 +121,10 @@ def system(session):
74121 session .install ("-e" , "." )
75122
76123 # Run py.test against the system tests.
77- session .run ("py.test" , "--quiet" , system_test_path , * session .posargs )
78-
79-
80- @nox .session (python = "3.7" )
81- def blacken (session ):
82- """Run black.
83-
84- Format code to uniform standard.
85- """
86- session .install ("black" )
87- session .run (
88- "black" ,
89- "google" ,
90- "tests" ,
91- "docs" ,
92- "--exclude" ,
93- ".*/proto/.*|.*/gapic/.*|.*/.*_pb2.py" ,
94- )
95-
96-
97- @nox .session (python = "3.7" )
98- def lint (session ):
99- """Run linters.
100-
101- Returns a failure if the linters find linting errors or sufficiently
102- serious code quality issues.
103- """
104- session .install ("flake8" , "black" , * LOCAL_DEPS )
105- session .install ("." )
106- session .run (
107- "black" ,
108- "--check" ,
109- "google" ,
110- "tests" ,
111- "docs" ,
112- "--exclude" ,
113- ".*/proto/.*|.*/gapic/.*|.*/.*_pb2.py" ,
114- )
115- session .run ("flake8" , "google" , "tests" )
116-
117-
118- @nox .session (python = "3.7" )
119- def lint_setup_py (session ):
120- """Verify that setup.py is valid (including RST check)."""
121- session .install ("docutils" , "pygments" )
122- session .run ("python" , "setup.py" , "check" , "--restructuredtext" , "--strict" )
124+ if system_test_exists :
125+ session .run ("py.test" , "--quiet" , system_test_path , * session .posargs )
126+ if system_test_folder_exists :
127+ session .run ("py.test" , "--quiet" , system_test_folder_path , * session .posargs )
123128
124129
125130@nox .session (python = "3.7" )
@@ -130,6 +135,6 @@ def cover(session):
130135 test runs (not system test runs), and then erases coverage data.
131136 """
132137 session .install ("coverage" , "pytest-cov" )
133- session .run ("coverage" , "report" , "--show-missing" , "--fail-under=85 " )
138+ session .run ("coverage" , "report" , "--show-missing" , "--fail-under=80 " )
134139
135140 session .run ("coverage" , "erase" )
0 commit comments