python -m unittest discover

…should work fine when you have set everything up with a bit of forethought

If you see response ‘Ran 0 tests’ then try

touch tests/__init__.py

If you fail to create an empty __init__.py in your tests folder, then Python (rightly) will not recognise it [ as a module ]

Rerun your discover command and if missing __init__.py was holding you up, then you should now be further along.

Along the way you have just learned a little about project structure, and Python requirements generally for modularised code.

Advertisements

Image

For this particular project the setup.py contained the following line:

      install_requires=['bottle','python-memcached>=1.45'],

Note: if you use ‘memcache’ or ‘memcached’ instead of what is written, you will probably get a message like:

Couldn’t find index page for ‘memcache’ (maybe misspelled?)

remote: Reading http://pypi.python.org/simple/
remote: No local packages or download links found for memcache>=1.45
remote: Best match: None

GNU/Linux systems now have a new major Kernel version – 3.

Best way to test / report kernel in Python?

Example script – hosted on Bitbucket:

The Python at the link above, will report what it knows about your running kernel.

Example output:

Example output for Linux kernel 3.x

Python reports Linux 3

It is always good to know how powerful a new cloud server is, when you take delivery.

There are a range of benchmarks available, however for pure cpu, I like to use some Mathematics.

Programs that tax a processor for several hours, often will be compiled from source.

( Makes sense as if the thing is cpu intensive,
then it really is important for it to be tailored more closely,
to the features available on the underlying host )

Benchmarking with fabric example – hosted on Bitbucket:

The fabric file at the link above, will download the code to your server and run the benchmark.

The image below (click to resize fullscreen) shows the preparatory steps in action as witnessed through the fabric call on the local machine.

benchmarking server from fabric

fabric to benchmark

The Mathematics will run for anywhere between 1 and 15 hours, depending on the raw (single core) processing power on the server being benchmarked.

Fabric availability as standard package

Because Fabric relies on Python 2.5 or newer, you will have to do your own thinking, for CentOS 5 and RedHat 5 (which have python 2.4 by default)

Here is a useful link for Python 2.5 and fabric on rpm based ‘5’ series systems.

Here is a fabric rpm in fedora that assumes a Python version 2.7 or newer.