Testing Python projects with commands like make -j4
23 Apr 2020Having used pytest, nose, nose2 for many months and faced random issues like some tests would fail when running in a set (not concurrently) together with all other tests but pass if ran alone (whereas the target use case was to be run in its own process alone), and also random issues in getting tests to continue from the last failed one (in larger projects with 300+ integration tests) - I was looking for a solution that can run tests concurrently, in their own processes, and can continue from the last failed (not having to start again from the first test). Tried pytest, nose, nose2 but they dont seem to fit this need although one of them had a continue from last failed feature but randomly it would start all again..
What if we can use the tried in true 'GNU Make' as used in most C projects like the Linux kernel sources to run python tests? It can run concurrently like make -j4
, it continues from last failed just by running make
, start over with make clean
then make
- yes it worked perfectly for my needs! Just make sure you handle __main__
to run your test function in each test_<test name>.py
file so that each test could be run with python test_<test name>.py
.
To use this, just use copy this Makefile from my github repo into your python project folder then run make
: https://github.com/ykasidit/python_make_test_example/blob/master/Makefile
Recent articles by category:
Software HOWTOs
- How to use Bluetooth Xbee Module on ardusimple ublox F9 UART1 with UBX message support instead of UART2 » 02 Jan 2020
- How to connect the Ardusimple ublox F9 board to u-center in Windows 7 » 02 Jan 2020
- Android force WCDMA or GSM or AUTO from shell » 10 Oct 2012
- Use your Nokia to change PowerPoint Presentation Slides » 14 Jan 2012
- วิธีทำให้ HTC Rhyme พิมพ์ไทยแต่ใช้เมนูอังกฤษ » 23 Dec 2011
- Nokia C5 Backup Contacts to Memory Card » 22 Aug 2011
- How to use your Samsung Jet to change Powerpoint slides on computer » 07 Aug 2011
More howto articles...
Programming - Software Development
- Testing Python projects with commands like make -j4 » 23 Apr 2020
- Android NDK Get IMSI from C code » 26 Jun 2013
- Android NDK Get IMEI Natively » 26 Nov 2012
- Writing good clean portable quality ANSI C code » 01 Sep 2011
- Windows native C programming - Simulate a keyboard key-press event » 30 Aug 2011
- Windows C programming - Simulate a Mouse Click » 30 Aug 2011
- Windows C C++ - Set and Get Registry Keys » 30 Aug 2011
More programming articles...
Ethics - Moral philosophy
- How to be mentally strong » 14 Jan 2011
- Your Value » 03 Mar 2010
More moral articles...
Giving thanks and praises to God/Nature
- Thanking God/Nature for Water » 20 May 2010
More thanks articles...
Other topics - Uncategorized
- กุรอานแปลไทยสำหรับโทรศัพท์มือถือ Android, Nokia, Samsung, HTC และ BlackBerry » 14 Jan 2012
- Software Morality » 07 Mar 2010
- Don't use Facebook » 09 Dec 2009
- The Free-Software Movement » 22 Aug 2009
- Google's Linux OS Chrome OS » 02 Aug 2009
- Sitting tips from Sidiz » 15 Apr 2009
- Try listen this Daniel Masson » 05 Mar 2009
More uncategorized articles...
This ClearEvo.com blog is powered by Debian GNU/Linux, running lighttpd, generated using jekyll on Ubuntu.