Python Unittest Framework for Visual Effects (Under Development)

This is one of my long term plan, I started doing Test Driven Development(TDD) for last 4-5 year. It changed the way, how I did my developments.

As a FX artist become developer, I use to write codes in single files/modules. Every functions, variable, etc… will be in the same module. Once my lead ask me to write unittests for my python tools, it was a shock for me. I don’t know what to do(actually don’t know, what a unittest is in python). Started looking into others tests and codes. Be honest, it didn’t took a whole lot of time to understand it. Once I understood how TDD works, or how you can write a testable code. It is like playing a game.

I was trying to make as framework for testing the code I develops for me. And I finally have a starting point for that. I started a new PyPi project and added a basic structure now.

PyPi Project : bcTesting
PyPi Page : https://pypi.python.org/pypi/bcTesting
GitHub Link : https://github.com/barishcb/testing

Installation

Installing bcTesting is very simple. Once you download and unzip the package, you just have to execute the standard python setup.py install. The setup script will then place the bcTesting module into site-packages in your Python’s installation library.

Alternatively, since bcTesting is listed in the Python Package Index (PyPI), you can install it using your favorite Python packaging/distribution tool, for example with:

It’s recommended to run _build_tables.py in the bcTesting code directory after installation to make sure the parsing tables are pre-generated. This can make your code run faster.

How to Use

Using bcTesting is very simple. As it is just extension of testtools, you can directly import it and use it in your code. You have to replace bcTesting.testBase.TestCase insted of  unittest.TestCase or teststools.TestCase.

TODO

  • Testing Framework for Autodesk Maya (Currently under development)
  • Testing Framework for The Foundry Nuke
  • Testing Framework for The Foundry Katana

Example Project

If you want to look into the implementation please check this project.

Project : bcTools
GitHub Link : https://github.com/barishcb/tools

Your Suggestions

I hope this will once the project is stable and matured. It will make your like easy as a visual effect python developer.  This is still under development, so there will issues feel free to contact me. Aslo hoping suggestions and improvements  also.

Sublime Text 2 : Python – Search And Replace Tips(Regual Expression)

Here is some tips and tricks that I used to clean my python scripts before putting it for code review. These are some very basic of search and replace that you can do in Sublime Text 2. Improve these as you needed and you can speed up your work by some margin.

  1. Add Space between comma(,) and a letter
    Find What : “,((?! ).)”
    Replace With : “, $1”
  2. Adding Space before and after operators(+, *, -, /, =)
    Find What : “((?! ).)(+|*|-|/|=|%)((?! ).)”
    Replace With : “$1 $2 $3”
  3. Remove space after “(“
    Find What : “(()( )”
    Replace With : “$1”
  4. Remove space before “)”
    Find What : “( )())”
    Replace With : “$2”
  5. Remove space at the end of line
    Find What : “(.)( )(n)”
    Replace With : “$1$3”

Maya-Cutter Integration For MEL Scripting

This is a small tip for mel newbies to use cutter. Cutter is a worderfull text editor developed by Mr. Malcolm Kesson. it is very usefull for those who are useing Pixar’s Render Man. It helps a lot in Renderman Shader Development. Cutter supports number of languages like Python, MEL, RSL, Rib, TCL, Shake, MI(Mental Images), Batch…and lot. I am planning to add more MEL tutorials uses cutter.