Most viewed recipes tagged "assertions"http://code.activestate.com/recipes/tags/assertions/views/2017-01-17T20:05:10-08:00ActiveState Code RecipesClassifying letters as vowels or consonants and counting their frequencies (Python)
2017-01-17T20:05:10-08:00Vasudev Ramhttp://code.activestate.com/recipes/users/4173351/http://code.activestate.com/recipes/580749-classifying-letters-as-vowels-or-consonants-and-co/
<p style="color: grey">
Python
recipe 580749
by <a href="/recipes/users/4173351/">Vasudev Ram</a>
(<a href="/recipes/tags/assertions/">assertions</a>, <a href="/recipes/tags/comprehension/">comprehension</a>, <a href="/recipes/tags/dict/">dict</a>, <a href="/recipes/tags/dictionaries/">dictionaries</a>, <a href="/recipes/tags/dict_comp/">dict_comp</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/python2/">python2</a>, <a href="/recipes/tags/tuple/">tuple</a>, <a href="/recipes/tags/unpack/">unpack</a>).
</p>
<p>This recipe shows how to take a string as input and classify the characters in it as vowels, consonants or neither. The frequency of each vowel is calculated and the frequency of all the consonants in total is calculated. The program logic is fairly simple, and uses a dictionary comprehension and a dict; the more interesting thing about it, is that it illustrates 8 Python language features in under 35 lines of code.</p>
<p>More details and sample output here:</p>
<p><a href="https://jugad2.blogspot.in/2017/01/classifying-letters-and-counting-their.html" rel="nofollow">https://jugad2.blogspot.in/2017/01/classifying-letters-and-counting-their.html</a></p>
Poor Man unit tests (Python)
2011-01-08T18:57:18-08:00Kevin L. Sitzehttp://code.activestate.com/recipes/users/4173535/http://code.activestate.com/recipes/577538-poor-man-unit-tests/
<p style="color: grey">
Python
recipe 577538
by <a href="/recipes/users/4173535/">Kevin L. Sitze</a>
(<a href="/recipes/tags/assertions/">assertions</a>, <a href="/recipes/tags/testing/">testing</a>, <a href="/recipes/tags/unittests/">unittests</a>).
</p>
<p>When building unit tests for modules many times using PyUnit feels like overkill. This is a simple implementation for testing single file modules.</p>