PyCon JP 2011 LT




        Oktest
a new style testing library for Python


                 makoto kuwata
          http://www.kuwata-lab.com/


        copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                                              1
unittest
           (python)


copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                        2
Too long! Hard to read & write!
                                     !                                  !




                copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                                            3
Test::More
                  (perl)


copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                        4
Easy to read & write! Kool!




      copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                              5
Oktest
           (python)


copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                        6
So Kooooooool!



                  copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                                          7
Kool Python!                                         Not kool. It's Java.
     Python                                                      Java




                            copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                                                                   8
ok() returns AssertionObject
                                  ok()        AssertionObject

       	    	 
                                                              	 

       	    	 
                     	                 	                   	             	 
	 	 
                                       	  	          	  	  	 
                                      Overrides '==' operator
                                       '=='




                 copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                                              9
Shows unified diff when '==' is failed.
	                                 '=='                    uniifed diff             (2.6   !)




                           copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                                                               10
Test Code                                 When Failed
  	          	 	 	 	 	 	 	 	 	 
        	  	  	  	 	 	 	 	 	 (no message)

  	       	 	 	 	 	 	 	 	 	 	 	 
       	  	  	 	 	 	 	 	 	 	 (no message)

  	          	 	 	 	 	 	 	 	 	 
  	     	  	  	 	 	 	 	 	 	 	  	  	  	  	 

                  Shows actual & expected values


            copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                                    11
unittest
           (python)


copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                        12
You must describe in [a-zA-Z0-9_]+
                                (         )                             _
         	 

	 	      	 
	 	 	 	          	  	  	                         	        	 
	 	 	 	                                                      	 

                         Duplicated. Not DRY!
                                                          DRY




                copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                                            13
Oktest
           (python)


copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                        14
Free text instead of method name!
                                                                        !




                copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                                            15
Any symbol or CJK available!



                copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                                        16
internal

                  	 	  	             	  	  	                           	    	 
                    	  	                           	 
	 	 	 	 	 	 	 	 	 	 	 	 	            	  	  	                           	    	 
                                                   	  	 
                 Set free text as method name,
               keeping with unittest compatibility
               unittest



               copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                                                 17
Fixture Injection
            in Oktest


   copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                           18
All test methods call the same 'setUp()'. Coarse-grained.
 Want to call different initializer for each test method.
                                 setUp()


         	 

	 	      	 
	 	 	 	                      	  	 
	 	 	 	                  	 	 	  	 

	 	      	 
	 	 	 	  	                                              	       	 

	 	      	 
	 	 	 	  	                                         	       	 
              copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                                      19
Calls provide_member() only
	 	      	                                         	 
	 	 	 	  	                                 	       	 
	 	      	                                    	 
	 	 	 	  	                            	       	 
                                                        Calls provide_team() only

              copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                                                    20
- 'A' depends on 'B' and 'C'
                                     - 'C' depends on 'D'
                                       A B C                      C     D

	 	      	                                    	                   	 
	 	      	                              	 	 	 	                   	 
	 	      	                                	 	 	                   	 
	 	      	                              	 	 	 	                   	 

	 	       	                                                    	 
	 	 	 	 	 	    	        	       	               	            	              	 
                    Dependencies are resolved automatically
                                           Oktest


                copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                                                 21
Equivarent to setUp()
                                        provide_xxx()       setUp()

	 	       	 
	 	 	 	                  	  	 
	 	 	 	        	                                     	            	     	 
	 	 	 	 	 	 
	 	 	 	             	 
                                  Equivarent to tearDown()
                                     release_xxx()        tearDown()

	 	       	                                                	 
	 	 	 	  	 
	 	 	 	 	 	 

                copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                                             22
Interested?


copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                        23
Oktest Python                                       Google Search




     copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                                    24
one more thing...


  copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                          25
Oktest for Node.js
      	             	    	 
	 	 	 	           	 	    	 
	 	 	 	         	 	 	    	 
	 	 	 	     	 	 	 	 	    	 

                                    	                      	 
	 	                                                	                    	 
	 	 	 	                                                    	                 	 
	 	 	 	 	 	     	 
	 	 	 	 	 	     	             	          	 
	 	 	 	 
	 	 


    	                                 	       	 
	 	 

                     copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                                                  26
thank you


copyright(c) 2011 kuwata-lab.com all rights reserved.
                                                        27

Oktest - a new style testing library for Python -

  • 1.
    PyCon JP 2011LT Oktest a new style testing library for Python makoto kuwata http://www.kuwata-lab.com/ copyright(c) 2011 kuwata-lab.com all rights reserved. 1
  • 2.
    unittest (python) copyright(c) 2011 kuwata-lab.com all rights reserved. 2
  • 3.
    Too long! Hardto read & write! ! ! copyright(c) 2011 kuwata-lab.com all rights reserved. 3
  • 4.
    Test::More (perl) copyright(c) 2011 kuwata-lab.com all rights reserved. 4
  • 5.
    Easy to read& write! Kool! copyright(c) 2011 kuwata-lab.com all rights reserved. 5
  • 6.
    Oktest (python) copyright(c) 2011 kuwata-lab.com all rights reserved. 6
  • 7.
    So Kooooooool! copyright(c) 2011 kuwata-lab.com all rights reserved. 7
  • 8.
    Kool Python! Not kool. It's Java. Python Java copyright(c) 2011 kuwata-lab.com all rights reserved. 8
  • 9.
    ok() returns AssertionObject ok() AssertionObject Overrides '==' operator '==' copyright(c) 2011 kuwata-lab.com all rights reserved. 9
  • 10.
    Shows unified diffwhen '==' is failed. '==' uniifed diff (2.6 !) copyright(c) 2011 kuwata-lab.com all rights reserved. 10
  • 11.
    Test Code When Failed (no message) (no message) Shows actual & expected values copyright(c) 2011 kuwata-lab.com all rights reserved. 11
  • 12.
    unittest (python) copyright(c) 2011 kuwata-lab.com all rights reserved. 12
  • 13.
    You must describein [a-zA-Z0-9_]+ ( ) _ Duplicated. Not DRY! DRY copyright(c) 2011 kuwata-lab.com all rights reserved. 13
  • 14.
    Oktest (python) copyright(c) 2011 kuwata-lab.com all rights reserved. 14
  • 15.
    Free text insteadof method name! ! copyright(c) 2011 kuwata-lab.com all rights reserved. 15
  • 16.
    Any symbol orCJK available! copyright(c) 2011 kuwata-lab.com all rights reserved. 16
  • 17.
    internal Set free text as method name, keeping with unittest compatibility unittest copyright(c) 2011 kuwata-lab.com all rights reserved. 17
  • 18.
    Fixture Injection in Oktest copyright(c) 2011 kuwata-lab.com all rights reserved. 18
  • 19.
    All test methodscall the same 'setUp()'. Coarse-grained. Want to call different initializer for each test method. setUp() copyright(c) 2011 kuwata-lab.com all rights reserved. 19
  • 20.
    Calls provide_member() only Calls provide_team() only copyright(c) 2011 kuwata-lab.com all rights reserved. 20
  • 21.
    - 'A' dependson 'B' and 'C' - 'C' depends on 'D' A B C C D Dependencies are resolved automatically Oktest copyright(c) 2011 kuwata-lab.com all rights reserved. 21
  • 22.
    Equivarent to setUp() provide_xxx() setUp() Equivarent to tearDown() release_xxx() tearDown() copyright(c) 2011 kuwata-lab.com all rights reserved. 22
  • 23.
  • 24.
    Oktest Python Google Search copyright(c) 2011 kuwata-lab.com all rights reserved. 24
  • 25.
    one more thing... copyright(c) 2011 kuwata-lab.com all rights reserved. 25
  • 26.
    Oktest for Node.js copyright(c) 2011 kuwata-lab.com all rights reserved. 26
  • 27.
    thank you copyright(c) 2011kuwata-lab.com all rights reserved. 27