Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Odd Unit Test Behavior
#1
I have this program:

"""
_test_all.py

Overall unit testing for the t_games project.
"""

import unittest

if __name__ == '__main__':
	test_suite = unittest.defaultTestLoader.discover('.', pattern = '*_test.py')
	unittest.TextTestRunner(verbosity = 1).run(test_suite)
This is in a folder with a bunch of other test code files. When I run it, I get two errors in the file interface_test.py:

Output:
====================================================================== ERROR: testAliasStatsTitle (t_games.t_tests.interface_test.InterfaceDoStatsTest) Test call arguments for Interface.do_stats for a specific game alias. ---------------------------------------------------------------------- Traceback (most recent call last): File "C:\Users\Craig\Documents\t_games\t_tests\interface_test.py", line 184, in testAliasStatsTitle self.assertIn('\nUnit Statistics\n', self.bot.info[0]) IndexError: list index out of range ====================================================================== FAIL: testAliasStatsAllGames (t_games.t_tests.interface_test.InterfaceDoStatsTest) Test stat groups shown for Interface.do_stats for a specific game alias. ---------------------------------------------------------------------- Traceback (most recent call last): File "C:\Users\Craig\Documents\t_games\t_tests\interface_test.py", line 179, in testAliasStatsAllGames self.assertEqual(1, len(self.bot.info)) AssertionError: 1 != 0
Note that self.bot is a dummy class, that stores any text sent to it in the info attribute. Normally this text would be sent to a class that would print the text. So I'm testing printing some text, and it appears to not be printing.

So I next run interface_test.py, because the full _test_all.py takes a half hour or more. The idea being to work on the problem, rerunning itnerface_test.py as I go to check on my progress, and then rerunning the full _test_all.py at the end to confirm the problem is solved.

The problem is that when I run interface_test.py, the tests don't cause an error. I'm running both programs from the same location using the command line: python t_games\t_tests\_test_all.py or python t_games\t_tests\interface_test.py. I've been running the tests in 2.7 (t_games is designed to be 2.7 and 3.x compatible). I just started the full run in 3.6 to see if I get the same issue there.

Any ideas as to the discrepancy?

Edit: All tests are running fine in 3.6.3, whether I run _test_all.py or interface_test.py. Ha! Unsupported for less than 24 hours and it's already causing me problems. : )
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
Odd Unit Test Behavior - by ichabod801 - Jan-01-2020, 09:19 PM
RE: Odd Unit Test Behavior - by Gribouillis - Jan-02-2020, 08:12 AM
RE: Odd Unit Test Behavior - by ichabod801 - Jan-02-2020, 02:25 PM
RE: Odd Unit Test Behavior - by ichabod801 - Jan-02-2020, 03:34 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Unit Testing Set Up and Use RockBlok 2 493 Jan-08-2024, 07:43 PM
Last Post: deanhystad
  How to test and import a model form computer to test accuracy using Sklearn library Anldra12 6 3,247 Jul-03-2021, 10:07 AM
Last Post: Anldra12
  Writing unit test results into a text file ateestructural 3 4,845 Nov-15-2020, 05:41 PM
Last Post: ateestructural
  How to write test cases for a init function by Unit test in python? binhduonggttn 2 3,175 Feb-24-2020, 12:06 PM
Last Post: Larz60+
  How to write test cases by Unit test for database configuration file? binhduonggttn 0 2,601 Feb-18-2020, 08:03 AM
Last Post: binhduonggttn
  Remove function and unit test ftg 5 3,622 Jan-07-2020, 03:10 PM
Last Post: ndc85430
  Define unit of measure of a number doug2019 3 2,439 Oct-15-2019, 03:43 PM
Last Post: jefsummers
  Unit testing - AssertRaises kerzol81 3 4,663 Oct-07-2019, 10:35 AM
Last Post: buran
  unit test roll die saladgg 5 4,264 Nov-06-2018, 11:39 PM
Last Post: stullis
  Would you unit test __init__ method? kilthar 1 31,218 Oct-18-2017, 05:31 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020