Running Python unittests from Command Line

This script will allow a Python unittest to be run from the command line. import unittest import testFile suite = unittest.TestLoader().loadTestsFromModule(testFile) unittest.TextTestRunner().run(suite) import unittest from fun import add class test_function(unittest.TestCase): def test_one(self): result = add(2,3) self.assertEquals(result, 5) def add(a,b): return a+b

Simple Python Unit Test

This simple Python unit-test tests two function. The first function adds two numbers and the second function uses list comprehensions to make a list of numbers from to 0 to n which are divisible by m. import unittest from add import addition, make_list class test_add_function(unittest.TestCase): def test_for_add(self): result = addition(1, 5) self.assertEqual(result, 6) def…Read More

Angular Service Example

The following code demonstrates how a service can be created in AngularJS. index.html <html> <head> <script src=””></script> <script src=””></script> <script src=””></script> <script src=””></script> <script src=”app.js”></script> <script src=”anotherModule.js”></script> </head> <body> <div ng-app=”mainModule” ng-controller=”mainController as alias”> <b>Invoice:</b> <p>The input is: {{alias.quantity}}</p> <div> Quantity: <input type=”number” min=”0″ ng-model=”alias.quantity”required> </div> <div><p>Add 4 and double it!</p></div> <div> <b>Result:</b> <span>{{}}</span> <button…Read More

Install Mongodb on Fedora 23

To install Mongodb on Fedora 23 go to On the Linux tab go to version RHEL 7 Linux 64-bit $ wget Untar the tarball $ tar -zxvf mongodb-linux-x86_64-rhel70-3.2.3.tgz $ echo $PATH $ sudo ln -s ~/Downloads/mongodb-linux-x86_64-rhel70-3.2.3/bin/mongo /usr/local/bin/mongod $ mongod –version MongoDB shell version: 3.2.3 $ mongo –version MongoDB shell version: 3.0.8 Make the…Read More