Usually when writing a test proves to be very difficult it means that you should split you class into smaller classes. In your case my first guess is that your calculate method should be in one class, and your approximate method (the one that uses the calculate method) should be in a different class. The second class would then use the first class.In your tests you could mock the test class, so that you can easily control what the calculate method will return.
If you are a pyDoubles user you can run your tests using doublex. However, we recommed the native doublex API for your new developments. Find out what test doubles are according to Gerard Meszaros.
Replaces the implementation of one or more methods in the object instance which plays the role of collaborator or dependency, returning the value that we explicitly write down in the test. A stub is actually a method but it is also common to use the noun stub for a class with stubbed methods. The stub does not have any kind or memory.
Stubs are used mainly for state validation or along with spies or mocks. Replaces the implementation as a stub does, but it is also able to register and remember what methods are called during the test execution and how they are invoked. They are used for interaction/behavior verification.
Contains the same features than the Stub and therefore the Spy, but it is very strict in the behavior specification it should expect from the System Under Tests. Before calling any method in the mock object, the framework should be told (in the test) which methods we expect to be called in order for them to succeed. Otherwise, the test will fail with an “UnexpectedBehavior” exception.
Mock objects are used when we have to be very precise in the behavior specification. They usually make the tests more fragile than a spy but still are necessary in many cases. It is common to use mock objects together with stubs in tests.
New to test doubles? A unit test is comprised of three parts: Arrange/Act/Assert or Given/When/Then or whatever you want to call them. The scenario has to be created, exercised, and eventually we verify that the expected behavior happened.
The test doubles framework is used to create the scenario (create the objects), and verify behavior after the execution but it does not make sense to invoke test doubles’ methods in the test code. If you call the doubles’ methods in the test code, you are testing the framework itself, which has been already tested (better than that, we crafted it using TDD). Make sure the calls to the doubles’ methods happen in your production code.
Why another framework? PyDoubles is inspired in mockito and jMock for Java, and also inspired in Rhino. Mocks for .Net.
There are other frameworks for Python that work really well, but after some time using them, we were not really happy with the syntax and the readability of the tests. Fragile tests were also a problem. Some well-known frameworks available for Python are: mocker, mockito-python, mock, pymox.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.