How to make the simplest unittests in Python

Testing your code is nearly a requirement (even more so in Ruby). Unittests are now the most vital elements for evaluating the quality/viability of a project. I was a little jealous of Ruby where you don’t have so much to write to implement unittests. Here is a simple example: [crayon-574b73518049e527730098/] Now, using Nose, you can get even shorter code. If you do standard Python projects, you’ll use a file. To use nose, you do not even need to specify the path where to find the tests, just add two lines (tests_require and test_suite) to call nosetest: [crayon-574b7351804aa619620208/] Now, to add tests, you just have to create a directory named tests (in the root of your project, where your resides, and then add a python file()s. No need to add a to set the directory as a module. Now just add simple python files, like : [crayon-574b7351804b2199648988/] ...(Read More)

Synchronization methods of a file with Puppet

Usually, to synchronize a file with remote hosts, using puppet, one would use the following pattern: file { "/etc/init.d/pvfs2-server": owner => root, group => root, mode => 755, source => "puppet:///files/pvfs2-server" } (using “source” to copy data as-is, and using “template(“filename”) to use a template structure as data). Or, if one wishes to directly set the content of the target file: file { "/etc/init.d/pvfs2-server": owner => root, group => root, mode => 755, source => "puppet:///files/pvfs2-server" } Please note that on the first line, for example ‘file { “/etc/mpd.conf”:’), the “/etc/mpd.conf” is a merge of two functionalities/concepts: Usually, the syntax is clear and simple: file { mon_fichier_mpd_conf: path => "/etc/mpd.conf", [...] } The first line is about the resource description. Its goal is to be able to reference to it a little later from another resources (Notify[], etc.). By putting directly the file path and name (I think it’s identified ...(Read More)