#!/bin/bash
# Run all the test_*.py unit tests and colourise the output
clear=$(tput op)
green=$(tput setaf 10)
red=$(tput setaf 9)
find . -iname "test_*.py" -printf 'pushd "%h";python3 "%f" 2>&1| sed -re \
"s/FAILED/'$red'FAILED'$clear'/" -e \
"s/^(F+)[.]?$|[.](F+)|(F+)[.]/'$red'F'$clear'/g" -e \
"s/OK/'$green'OK'$clear'/";popd> /dev/null\n' | bash
import unittest
import myproject
# test some things!
class test_things(unittest.TestCase):
result = None
real = None
def setUp(self):
self.real = myproject.check
def tearDown(self):
myproject.check = self.real
def check_Mock(self, row):
return self.result
def test_check_positive(self):
self.result = True
myproject.check = self.check_Mock
value = "Good value"
result = myproject.check(value)
self.assertTrue(result)
if __name__ == '__main__':
unittest.main(buffer=True)
unittest.main()
python3 test_myproject.py
python3 test_myproject.py test_things.test_check_positive
if __name__ == '__main__':
unittest.main(buffer=True)
email
root
flog archives
Disclaimer:
This page is by me for me, if you are not me then please be aware of the following
I am not responsible for anything that works or does not work including files and pages made available at www.jumpstation.co.uk
I am also not responsible for any information(or what you or others do with it) available at www.jumpstation.co.uk
In fact I'm not responsible for anything ever, so there!