unit testing...

64 views
Skip to first unread message

likage

unread,
Aug 10, 2016, 8:07:18 PM8/10/16
to Python Programming for Autodesk Maya
I am doing a simple unittest in maya while using chadvernon page as an example..

I tried something very simple such as creating a polyCube, while that works, I had thought of replacing the line with a custom node creation in which its code comes from my company's proprietary library.
As soon as I run this updated code, I got an error - ValueError: No object matches name: Stack in which I think it is telling me that it is unable to locate this particular node name..

However, if I run the same code in Maya editor, it is working perfectly fine.

So my question here would be:
1. How would I know what items are created in each scene (as mentioned in the site)?
2. Is it a reliable method that I tested my code in maya (just to check a few process) then copy into the testing? In the above example, I am already getting a failing result..

Justin Israel

unread,
Aug 10, 2016, 9:57:35 PM8/10/16
to python_in...@googlegroups.com
On Thu, Aug 11, 2016 at 12:07 PM likage <dissid...@gmail.com> wrote:
I am doing a simple unittest in maya while using chadvernon page as an example..

I tried something very simple such as creating a polyCube, while that works, I had thought of replacing the line with a custom node creation in which its code comes from my company's proprietary library.
As soon as I run this updated code, I got an error - ValueError: No object matches name: Stack in which I think it is telling me that it is unable to locate this particular node name..

Sounds right.
 

However, if I run the same code in Maya editor, it is working perfectly fine.

How are you running the unit tests?
 

So my question here would be:
1. How would I know what items are created in each scene (as mentioned in the site)?

What site? Where is the link?
 
2. Is it a reliable method that I tested my code in maya (just to check a few process) then copy into the testing? In the above example, I am already getting a failing result..

Could be. As long as you unit tests run under the same environment in which Maya was launched?
 

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/6b090880-7b39-46ee-8140-ace2c618c89b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Cesar Saez

unread,
Aug 11, 2016, 8:40:29 AM8/11/16
to python_in...@googlegroups.com
Hi there,

Looks like you are not launching Maya under the same environment during testing. Ask the pipeline guys at your company how are they launching maya, there's probably a good deal of environment variables per department/show in order to keep things under control.

Also, you usually don't create nodes but work with test scenes (well known input so you are certain of the desired output), you can test the creation of a group of nodes or create your inputs from scratch on each test suite but it makes no much sense (unless your project is all about building building/connecting nodes). Think about what you really want to test, testing a function creating a constrain (by calling a maya command/api under the hood) doesn't touch much logic and, unless maya is terrible broken, it will never fail. I strongly recommend to write failing tests first and then workout the code to make it pass, it's the easiest way to build a meaningful tests suite (it requires practice though).

Good luck,
Cheers!

likage

unread,
Aug 11, 2016, 1:55:42 PM8/11/16
to Python Programming for Autodesk Maya
I am doing a simple unittest in maya while using chadvernon page as an example..

I tried something very simple such as creating a polyCube, while that works, I had thought of replacing the line with a custom node creation in which its code comes from my company's proprietary library.
As soon as I run this updated code, I got an error - ValueError: No object matches name: Stack in which I think it is telling me that it is unable to locate this particular node name..

Sounds right

Why is this so? The reason I asked this is because since I am creating a mesh using cmds.polyCube(), shouldn't it work in the same way if I were to create something similar but the coding is different?

As for the link, I used http://www.chadvernon.com/blog/maya/unit-testing-in-maya/ as an example..

I am trying to check if something is within the project folder, if it is not, it will then looked into another project folder, grab that particular file and test it..
For example, if this char_rig does not exists in ProjectA, it will grab this char_rig in ProjectB (ProjectB is the main library) and used it for testing which is why I need to 'create'/ import the nodes.. Am I very wrong in this aspect, for unit-testing part?

At least that is how I test it if I am opening a Maya session..

Justin Israel

unread,
Aug 11, 2016, 2:47:37 PM8/11/16
to Python Programming for Autodesk Maya


On Fri, 12 Aug 2016, 5:55 AM likage <dissid...@gmail.com> wrote:
I am doing a simple unittest in maya while using chadvernon page as an example..

I tried something very simple such as creating a polyCube, while that works, I had thought of replacing the line with a custom node creation in which its code comes from my company's proprietary library.
As soon as I run this updated code, I got an error - ValueError: No object matches name: Stack in which I think it is telling me that it is unable to locate this particular node name..

Sounds right

Why is this so? The reason I asked this is because since I am creating a mesh using cmds.polyCube(), shouldn't it work in the same way if I were to create something similar but the coding is different?

The reason I had said that is because the error looked completely reasonable for a case where you have changed a bit of code. You didn't show us any code or context so all I had to go off of was one error string. When you want help debugging an error it is usually helpful to include the complete code context and what you changed. 

As for the link, I used http://www.chadvernon.com/blog/maya/unit-testing-in-maya/ as an example..

I am trying to check if something is within the project folder, if it is not, it will then looked into another project folder, grab that particular file and test it..
For example, if this char_rig does not exists in ProjectA, it will grab this char_rig in ProjectB (ProjectB is the main library) and used it for testing which is why I need to 'create'/ import the nodes.. Am I very wrong in this aspect, for unit-testing part?

At least that is how I test it if I am opening a Maya session..

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

Marcus Ottosson

unread,
Aug 11, 2016, 4:14:13 PM8/11/16
to python_in...@googlegroups.com

Also, another option is to create test scenes

There. Removed assumptions. :)


On 11 August 2016 at 19:47, Justin Israel <justin...@gmail.com> wrote:


On Fri, 12 Aug 2016, 5:55 AM likage <dissid...@gmail.com> wrote:
I am doing a simple unittest in maya while using chadvernon page as an example..

I tried something very simple such as creating a polyCube, while that works, I had thought of replacing the line with a custom node creation in which its code comes from my company's proprietary library.
As soon as I run this updated code, I got an error - ValueError: No object matches name: Stack in which I think it is telling me that it is unable to locate this particular node name..

Sounds right

Why is this so? The reason I asked this is because since I am creating a mesh using cmds.polyCube(), shouldn't it work in the same way if I were to create something similar but the coding is different?

The reason I had said that is because the error looked completely reasonable for a case where you have changed a bit of code. You didn't show us any code or context so all I had to go off of was one error string. When you want help debugging an error it is usually helpful to include the complete code context and what you changed. 

As for the link, I used http://www.chadvernon.com/blog/maya/unit-testing-in-maya/ as an example..

I am trying to check if something is within the project folder, if it is not, it will then looked into another project folder, grab that particular file and test it..
For example, if this char_rig does not exists in ProjectA, it will grab this char_rig in ProjectB (ProjectB is the main library) and used it for testing which is why I need to 'create'/ import the nodes.. Am I very wrong in this aspect, for unit-testing part?

At least that is how I test it if I am opening a Maya session..

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA035TfRQuramqwAxjztuHaxq8wOkyfymnCrToUtTjGS-g%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

Chad Vernon

unread,
Aug 11, 2016, 7:21:48 PM8/11/16
to Python Programming for Autodesk Maya
If you are running the tests from outside Maya, the code on my page sets up a clean MAYA_APP_DIR so it's in a predictable testing state each time you run the tests.  You'll need to modify the setup depending on how your studio sets up their environment.  In my code, it sets the MAYA_MODULE_PATH before starting up mayapy so you can edit it to add whatever your studio does to setup the environment.
Reply all
Reply to author
Forward
0 new messages