Skip to content

Commit 73b1fab

Browse files
SG-19308 pip install fix. (#237)
Fixes an issue where the cacert.pem inside the bundled certifi was included in a pip install. The tests have also been changed to allow the CI testing to test via the pip installed Python API, to ensure that we are including everything that needs to be included when pip installing. * Increase the amount of thumbnail request attempts. Co-authored-by: Philip Scadding <philip.scadding@autodesk.com>
1 parent 9c90991 commit 73b1fab

File tree

6 files changed

+15
-9
lines changed

6 files changed

+15
-9
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,13 @@ matrix:
4545
# command to install dependencies
4646
install:
4747
- pip install -r tests/ci_requirements.txt
48+
- pip install . -U
4849
before_script:
4950
- cp ./tests/example_config ./tests/config
5051
# Run flake and then run tests
5152
script:
5253
- if [ -n "$RUN_FLAKE" = true ]; then flake8; fi
53-
- coverage run -m nose --config="nose.cfg"
54+
- cd tests && coverage run -m nose --no-path-adjustment
5455
after_success: coveralls
5556
notifications:
5657
email:

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@
3737
packages=find_packages(exclude=('tests',)),
3838
script_args=script_args,
3939
include_package_data=True,
40-
package_data={'': ['cacerts.txt']},
40+
package_data={'': ['cacerts.txt', 'cacert.pem']},
4141
zip_safe=False,
4242
)

tests/base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
def skip(f):
2424
return lambda self: None
2525

26-
CONFIG_PATH = 'tests/config'
27-
2826

2927
class TestBase(unittest.TestCase):
3028
'''Base class for tests.
@@ -57,7 +55,9 @@ def setUpClass(cls):
5755
# Since the file is read and never modified, we will only read
5856
# it once in memory and be done.
5957
cls.config = SgTestConfig()
60-
cls.config.read_config(CONFIG_PATH)
58+
cur_folder = os.path.dirname(os.path.abspath(__file__))
59+
config_path = os.path.join(cur_folder, "config")
60+
cls.config.read_config(config_path)
6161

6262
def setUp(self, auth_mode='ApiUser'):
6363
self.human_login = self.config.human_login

tests/run_appveyor.bat

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@
1414

1515
copy tests\example_config tests\config
1616
%PYTHON%\Scripts\pip install -r tests/ci_requirements.txt
17-
%PYTHON%\Scripts\nosetests.exe -v --config="nose.cfg"
17+
%PYTHON%\Scripts\pip install . -U
18+
cd tests
19+
%PYTHON%\Scripts\nosetests.exe -v --no-path-adjustment

tests/test_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
from . import base
4040

41-
THUMBNAIL_MAX_ATTEMPTS = 12
41+
THUMBNAIL_MAX_ATTEMPTS = 18
4242
THUMBNAIL_RETRY_INTERAL = 5
4343
TRANSIENT_IMAGE_PATH = "images/status/transient"
4444

tests/tests_unit.py renamed to tests/test_unit.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,9 +453,12 @@ def test_found_correct_cert(self):
453453
isn't set), is the one bundled with this API
454454
"""
455455
# Get the path to the cert file we expect the Shotgun API to find
456-
cur_path = os.path.dirname(os.path.abspath(__file__))
457456
cert_path = os.path.normpath(
458-
os.path.join(cur_path, "..", "shotgun_api3", "lib", "certifi", "cacert.pem")
457+
# Get the path relative to where we picked up the API and not relative
458+
# to file on disk. On CI we pip install the API to run the tests
459+
# so we have to pick the location from the installed copy.
460+
# Call dirname to remove from __init__.py
461+
os.path.join(os.path.dirname(api.__file__), "lib", "certifi", "cacert.pem")
459462
)
460463
# Now ensure that the path the SG API has found is correct.
461464
self.assertEquals(cert_path, self.certs)

0 commit comments

Comments
 (0)