Profile

Cover photo
65 followers|64,610 views
AboutPostsPhotosVideos

Stream

The Digital Cat

Shared publicly  - 
 
As already stressed in the two introductory posts on TDD (you can find them here) testing requires to write some code that uses the functions and objects you are going to develop. This means that you need to isolate a given (external) function that is part of your public API and demonstrate that it works with standard inputs and in edge cases.

For example, if you are going to develop an object that stores percentages (such as for example poll results), you should test the following conditions: the class can store a standard percentage such as 42%, the class shall give an error if you try to store a negative percentage, the class shall give an error if you store a percentage greater than 100%.

Tests shall be idempotent and isolated. Idempotent in mathematics and computer science identifies a process that can be run multiple times without changing the status of the system. Isolated means that a test shall not change its behaviour depending on previous executions of itself, nor depend on the previous execution (or missing execution) of other tests.

Such restrictions, which guarantee that your tests are not passing due to a temporary configuration of the system or the order in which they are run, can raise big issues when dealing with external libraries and systems, or with intrinsically mutable concepts such as time. In the testing discipline, such issues are mostly faced using mocks, that is objects that pretend to be other objects.

In this series of posts I am going to review the Python mock library and exemplify its use. I will not cover everything you may do with mock, obviously, but hopefully I'll give you the information you need to start using this powerful library.

#Python   #TDD  
1
Add a comment...

The Digital Cat

Shared publicly  - 
 
The second part of the small series on Python OOP and TDD

#python #oop #tdd #TheDigitalCat  
1
Add a comment...
 
A simple example of #Python #OOP development (with #TDD ) - Part 1

#TheDigitalCat
2
1
Jacob Zimmerman's profile photoThe Digital Cat's profile photo
2 comments
 
You are right, honestly I did not think about _radd_() and _rsub_(). I'll try and find a way to add them to the post or to the second part. About the _str_() implementation your change makes perfectly sense.

Thank you!
Add a comment...
 
19 Apr 2015 - 9AM - Florence
goo.gl/HdlDZQ

+PyCon Italia #TheDigitalCat
2
1
Add a comment...
 
19 Apr 2015 - 9AM - Florence
goo.gl/HdlDZQ

+PyCon Italia #TheDigitalCat
1
Add a comment...
Have them in circles
65 people
reegan A Reegan's profile photo
Welington Carlos's profile photo
Sean Liu's profile photo
Ridwan Ahmed Khan's profile photo
Jesaja Everling's profile photo
Piers Storey's profile photo
Skift Creative's profile photo
Vadim Latypov's profile photo
Star Willy's profile photo

Communities

9 communities

The Digital Cat

Stories (success or horror)  - 
 
Using gitflow with GitHub: a simple procedure (and a working tool).

http://goo.gl/GAxbua

#TheDigitalCat #git #github #gitflow  
1
2
Add a comment...
 
Python decorators: metaprogramming with style

goo.gl/EiWWRt

#Python #TheDigitalCat

Thanks +Bruce Eckel  for your original posts
2
3
Graham Dumpleton's profile photoBruce Eckel's profile photoThe Digital Cat's profile photo
4 comments
 
Thank you very much Bruce. I'm sorry the Patterns book has somehow failed!
Add a comment...

The Digital Cat

Shared publicly  - 
1
1
Jacob Zimmerman's profile photoThe Digital Cat's profile photo
2 comments
 
Thank you for the link! I'm going to read it.

This image was sort of a short advertisement for my PyConIT OOP tutorial where I questioned the fact that OOP is based on inheritance. It is based on delegation, which can be implemented both through inheritance and composition.

I showed there a provocative "composed inheritance" slide to show that in Python you can push composition to the limit through _getattr_() (but I always prefer good sense over extreme solutions).
Add a comment...

The Digital Cat

Shared publicly  - 
 
A humble try to learn Scala.
1
Add a comment...
 
Object-Oriented Python from scratch tutorial

PyCon 6 - Firenze 19 aprile - 14:30
https://www.pycon.it/conference/talks/oop-object-oriented-python-partendo-da-zero

Code available in IPython Notebook format

https://github.com/lgiordani/oopy.git

IPython Notebook is highly recommended for this tutorial, it allows to easily experiment with the code. (http://ipython.org/notebook.html)

Tutorial in Italian language.
Slides (in English) will be available on Slideshare and Speaker Deck
1
1
Add a comment...
People
Have them in circles
65 people
reegan A Reegan's profile photo
Welington Carlos's profile photo
Sean Liu's profile photo
Ridwan Ahmed Khan's profile photo
Jesaja Everling's profile photo
Piers Storey's profile photo
Skift Creative's profile photo
Vadim Latypov's profile photo
Star Willy's profile photo
Communities
9 communities
Story
Tagline
Learning is understanding
Introduction
Cats are curious animals: so the title implies this is blog about curiosity in the digital world.

Learning is not a matter of procedures. Learning is understanding and understanding is asking why and how.