testcase

Rounding float numbers within a dictionary

Rounding float numbers within a dictionary Question: I am trying out a challenge at codewars.com, but I cannot figure out why my code cannot pass the test cases.I am supposed to round of any float numbers to 2 decimal points within a dictionary. I have done some research and found Round off dict values to …

Total answers: 2

Persist variable changes between tests in unittest?

Persist variable changes between tests in unittest? Question: How do I persist changes made within the same object inheriting from TestCase in unitttest? from unittest import TestCase, main as unittest_main class TestSimpleFoo(TestCase): foo = ‘bar’ def setUp(self): pass def test_a(self): self.assertEqual(self.foo, ‘bar’) self.foo = ‘can’ def test_f(self): self.assertEqual(self.foo, ‘can’) if __name__ == ‘__main__’: unittest_main() I.e.: …

Total answers: 3

abstract test case using python unittest

abstract test case using python unittest Question: Is it possible to create an abstract TestCase, that will have some test_* methods, but this TestCase won’t be called and those methods will only be used in subclasses? I think I am going to have one abstract TestCase in my test suite and it will be subclassed …

Total answers: 13