test: update nox file to build and test wheels (#1295)
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
- [x] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/google-api-python-client/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
- [x] Ensure the tests and linter pass
- [x] Code coverage does not decrease (if any source code was changed)
- [x] Appropriate docs were updated (if necessary)
Fixes #1235 🦕
In an attempt to verify that this is a fix for #1235 I'm going push a commit that removes the fix from #1221 in this PR and confirm that the checks fail.
diff --git a/noxfile.py b/noxfile.py
index cbcfbb6..4808772 100644
--- a/noxfile.py
+++ b/noxfile.py
@@ -16,6 +16,8 @@
import sys
import nox
+import os
+import shutil
test_dependencies = [
"django>=2.0.0",
@@ -58,9 +60,22 @@
],
)
def unit(session, oauth2client):
+ # Clean up dist and build folders
+ shutil.rmtree('dist', ignore_errors=True)
+ shutil.rmtree('build', ignore_errors=True)
+
session.install(*test_dependencies)
session.install(oauth2client)
- session.install('.')
+
+ # Create and install wheels
+ session.run('python3', 'setup.py', 'bdist_wheel')
+ session.install(os.path.join('dist', os.listdir('dist').pop()))
+
+ # Run tests from a different directory to test the package artifacts
+ root_dir = os.path.dirname(os.path.realpath(__file__))
+ temp_dir = session.create_tmp()
+ session.chdir(temp_dir)
+ shutil.copytree(os.path.join(root_dir, 'tests'), 'tests')
# Run py.test against the unit tests.
session.run(