Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move import of ufeSelectCmd inside selectPath() function in ufeUtils #1237

Conversation

mattyjams
Copy link
Contributor

Attempting to import ufeSelectCmd before maya.standalone.initialize() has been called will raise an ImportError and cause tests to fail. For example, this would be the case for test cases that are decorated with the unittest.skipUnless() decorator and use ufeUtils.ufeFeatureSetVersion(), since the decorator will be executed before setUpClass has a chance to run and initialize maya.standalone.

This change addresses that by pushing the import of ufeSelectCmd into the selectPath() function where it is used rather than having it at the top of the file. This ensures that the ufeUtils module can be imported and ufeUtils.ufeFeatureSetVersion() can be called safely before maya.standalone.initialize().

Note that this does not currently manifest as an issue when running the unit tests using the CMake infrastructure in this repo since we inject the Maya standalone initialization early in every test:

import maya.standalone

We do not do that in our internal test infrastructure, which is why this is problematic for us. Ultimately, it seems like it would be preferable not do to that in CMake either and make sure that every test script can run successfully on its own without requiring additional patching from the test harness. There are likely other changes along the lines of this one needed to make that a reality, but this is hopefully one more small step in that direction.

Attempting to import ufeSelectCmd before maya.standalone.initialize() has been
called will raise an ImportError and cause tests to fail. For example, this
would be the case for test cases that are decorated with the
unittest.skipUnless() decorator and use ufeUtils.ufeFeatureSetVersion(), since
the decorator will be executed before setUpClass has a chance to run and
initialize maya.standalone.

This change addresses that by pushing the import of ufeSelectCmd into the
selectPath() function where it is used rather than having it at the top of the
file. This ensures that the ufeUtils module can be imported and
ufeUtils.ufeFeatureSetVersion() can be called safely before
maya.standalone.initialize().
@mattyjams mattyjams added the unit test Related to unit tests (both python or c++) label Mar 5, 2021
@kxl-adsk kxl-adsk requested a review from ppt-adsk March 5, 2021 20:49
@kxl-adsk kxl-adsk added the ready-for-merge Development process is finished, PR is ready for merge label Mar 8, 2021
@kxl-adsk kxl-adsk merged commit a316163 into Autodesk:dev Mar 8, 2021
@mattyjams mattyjams deleted the pr/allow_ufeUtils_ufeFeatureSetVersion_before_maya_standalone_initialize branch March 9, 2021 00:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-merge Development process is finished, PR is ready for merge unit test Related to unit tests (both python or c++)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants